@@ -58,11 +58,11 @@ discard block |
||
| 58 | 58 | 'valeur' => $adresse_ldap |
| 59 | 59 | ], |
| 60 | 60 | 'port_ldap' => [ |
| 61 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 61 | + 'label' => _T('entree_port_annuaire').'<br />'._T('texte_port_annuaire'), |
|
| 62 | 62 | 'valeur' => $port_ldap |
| 63 | 63 | ], |
| 64 | 64 | 'tls_ldap' => [ |
| 65 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 65 | + 'label' => '<b>'._T('tls_ldap').'</b>', |
|
| 66 | 66 | 'valeur' => $tls_ldap, |
| 67 | 67 | 'alternatives' => [ |
| 68 | 68 | 'non' => _T('item_non'), |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ] |
| 81 | 81 | ) |
| 82 | 82 | |
| 83 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 83 | + . "\n<p>"._T('texte_acces_ldap_anonyme_1').'</p>' |
|
| 84 | 84 | . fieldset( |
| 85 | 85 | _T('connexion_ldap'), |
| 86 | 86 | [ |
@@ -12,89 +12,89 @@ |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | function install_etape_ldap1_dist() { |
| 19 | - $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | - ? _INSTALL_HOST_LDAP |
|
| 21 | - : 'localhost'; |
|
| 19 | + $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 20 | + ? _INSTALL_HOST_LDAP |
|
| 21 | + : 'localhost'; |
|
| 22 | 22 | |
| 23 | - $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | - ? _INSTALL_PORT_LDAP |
|
| 25 | - : 389; |
|
| 23 | + $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 24 | + ? _INSTALL_PORT_LDAP |
|
| 25 | + : 389; |
|
| 26 | 26 | |
| 27 | - $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | - ? _INSTALL_TLS_LDAP |
|
| 29 | - : 'non'; |
|
| 27 | + $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 28 | + ? _INSTALL_TLS_LDAP |
|
| 29 | + : 'non'; |
|
| 30 | 30 | |
| 31 | - $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | - ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | - : 3; // on essaie 2 en cas d'echec |
|
| 31 | + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 32 | + ? _INSTALL_PROTOCOLE_LDAP |
|
| 33 | + : 3; // on essaie 2 en cas d'echec |
|
| 34 | 34 | |
| 35 | - $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | - ? _INSTALL_USER_LDAP |
|
| 37 | - : ''; |
|
| 35 | + $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 36 | + ? _INSTALL_USER_LDAP |
|
| 37 | + : ''; |
|
| 38 | 38 | |
| 39 | - $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | - ? _INSTALL_PASS_LDAP |
|
| 41 | - : ''; |
|
| 39 | + $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 40 | + ? _INSTALL_PASS_LDAP |
|
| 41 | + : ''; |
|
| 42 | 42 | |
| 43 | - $minipage = new Installation(); |
|
| 44 | - echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 43 | + $minipage = new Installation(); |
|
| 44 | + echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 45 | 45 | |
| 46 | - echo info_etape( |
|
| 47 | - _T('titre_connexion_ldap'), |
|
| 48 | - info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 49 | - ); |
|
| 46 | + echo info_etape( |
|
| 47 | + _T('titre_connexion_ldap'), |
|
| 48 | + info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | - echo generer_form_ecrire('install', ( |
|
| 52 | - "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 53 | - . fieldset( |
|
| 54 | - _T('entree_adresse_annuaire'), |
|
| 55 | - [ |
|
| 56 | - 'adresse_ldap' => [ |
|
| 57 | - 'label' => _T('texte_adresse_annuaire_1'), |
|
| 58 | - 'valeur' => $adresse_ldap |
|
| 59 | - ], |
|
| 60 | - 'port_ldap' => [ |
|
| 61 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 62 | - 'valeur' => $port_ldap |
|
| 63 | - ], |
|
| 64 | - 'tls_ldap' => [ |
|
| 65 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 66 | - 'valeur' => $tls_ldap, |
|
| 67 | - 'alternatives' => [ |
|
| 68 | - 'non' => _T('item_non'), |
|
| 69 | - 'oui' => _T('item_oui') |
|
| 70 | - ] |
|
| 71 | - ], |
|
| 72 | - 'protocole_ldap' => [ |
|
| 73 | - 'label' => _T('protocole_ldap'), |
|
| 74 | - 'valeur' => $protocole_ldap, |
|
| 75 | - 'alternatives' => [ |
|
| 76 | - '3' => '3', |
|
| 77 | - '2' => '2' |
|
| 78 | - ] |
|
| 79 | - ] |
|
| 80 | - ] |
|
| 81 | - ) |
|
| 51 | + echo generer_form_ecrire('install', ( |
|
| 52 | + "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 53 | + . fieldset( |
|
| 54 | + _T('entree_adresse_annuaire'), |
|
| 55 | + [ |
|
| 56 | + 'adresse_ldap' => [ |
|
| 57 | + 'label' => _T('texte_adresse_annuaire_1'), |
|
| 58 | + 'valeur' => $adresse_ldap |
|
| 59 | + ], |
|
| 60 | + 'port_ldap' => [ |
|
| 61 | + 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 62 | + 'valeur' => $port_ldap |
|
| 63 | + ], |
|
| 64 | + 'tls_ldap' => [ |
|
| 65 | + 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 66 | + 'valeur' => $tls_ldap, |
|
| 67 | + 'alternatives' => [ |
|
| 68 | + 'non' => _T('item_non'), |
|
| 69 | + 'oui' => _T('item_oui') |
|
| 70 | + ] |
|
| 71 | + ], |
|
| 72 | + 'protocole_ldap' => [ |
|
| 73 | + 'label' => _T('protocole_ldap'), |
|
| 74 | + 'valeur' => $protocole_ldap, |
|
| 75 | + 'alternatives' => [ |
|
| 76 | + '3' => '3', |
|
| 77 | + '2' => '2' |
|
| 78 | + ] |
|
| 79 | + ] |
|
| 80 | + ] |
|
| 81 | + ) |
|
| 82 | 82 | |
| 83 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 84 | - . fieldset( |
|
| 85 | - _T('connexion_ldap'), |
|
| 86 | - [ |
|
| 87 | - 'login_ldap' => [ |
|
| 88 | - 'label' => _T('texte_login_ldap_1'), |
|
| 89 | - 'valeur' => $login_ldap |
|
| 90 | - ], |
|
| 91 | - 'pass_ldap' => [ |
|
| 92 | - 'label' => _T('entree_passe_ldap'), |
|
| 93 | - 'valeur' => $pass_ldap |
|
| 94 | - ] |
|
| 95 | - ] |
|
| 96 | - ) |
|
| 97 | - . bouton_suivant())); |
|
| 83 | + . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 84 | + . fieldset( |
|
| 85 | + _T('connexion_ldap'), |
|
| 86 | + [ |
|
| 87 | + 'login_ldap' => [ |
|
| 88 | + 'label' => _T('texte_login_ldap_1'), |
|
| 89 | + 'valeur' => $login_ldap |
|
| 90 | + ], |
|
| 91 | + 'pass_ldap' => [ |
|
| 92 | + 'label' => _T('entree_passe_ldap'), |
|
| 93 | + 'valeur' => $pass_ldap |
|
| 94 | + ] |
|
| 95 | + ] |
|
| 96 | + ) |
|
| 97 | + . bouton_suivant())); |
|
| 98 | 98 | |
| 99 | - echo $minipage->installFinPage(); |
|
| 99 | + echo $minipage->installFinPage(); |
|
| 100 | 100 | } |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND'); |
| 83 | 83 | if (!isset($cache[$serveur][$table][$recherche])) { |
| 84 | 84 | $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : ''); |
| 85 | - $hash = substr(md5($recherche . $table), 0, 16); |
|
| 86 | - $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')"; |
|
| 85 | + $hash = substr(md5($recherche.$table), 0, 16); |
|
| 86 | + $where = "(resultats.recherche='$hash' AND resultats.table_objet=".sql_quote($table)." AND resultats.serveur='$hash_serv')"; |
|
| 87 | 87 | $row = sql_fetsel( |
| 88 | 88 | 'recherche', |
| 89 | 89 | 'spip_resultats AS resultats', |
| 90 | - $where . " AND $where_resultat_recent", |
|
| 90 | + $where." AND $where_resultat_recent", |
|
| 91 | 91 | '', |
| 92 | 92 | '', |
| 93 | 93 | '0,1' |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | foreach ($listes_ids as $p => $ids) { |
| 199 | - $select .= "+$p*(" . |
|
| 199 | + $select .= "+$p*(". |
|
| 200 | 200 | sql_in("$table.$primary", $ids, '', $serveur) |
| 201 | 201 | . ') '; |
| 202 | 202 | } |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/rechercher'); |
| 23 | 23 | if (!defined('_DELAI_CACHE_resultats')) { |
| 24 | - define('_DELAI_CACHE_resultats', 600); |
|
| 24 | + define('_DELAI_CACHE_resultats', 600); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -48,126 +48,126 @@ discard block |
||
| 48 | 48 | * @return array |
| 49 | 49 | */ |
| 50 | 50 | function inc_prepare_recherche_dist( |
| 51 | - $recherche, |
|
| 52 | - $table = 'articles', |
|
| 53 | - $cond = false, |
|
| 54 | - $serveur = '', |
|
| 55 | - $modificateurs = [], |
|
| 56 | - $primary = '' |
|
| 51 | + $recherche, |
|
| 52 | + $table = 'articles', |
|
| 53 | + $cond = false, |
|
| 54 | + $serveur = '', |
|
| 55 | + $modificateurs = [], |
|
| 56 | + $primary = '' |
|
| 57 | 57 | ) { |
| 58 | - $where = null; |
|
| 59 | - $rows = null; |
|
| 60 | - static $cache = []; |
|
| 61 | - $delai_fraicheur = min( |
|
| 62 | - \_DELAI_CACHE_resultats, |
|
| 63 | - time() - ($GLOBALS['meta']['derniere_modif'] ?? 0) |
|
| 64 | - ); |
|
| 65 | - |
|
| 66 | - // si recherche n'est pas dans le contexte, on va prendre en globals |
|
| 67 | - // ca permet de faire des inclure simple. |
|
| 68 | - if (!isset($recherche) && isset($GLOBALS['recherche'])) { |
|
| 69 | - $recherche = $GLOBALS['recherche']; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // traiter le cas {recherche?} |
|
| 73 | - if ($cond && !strlen($recherche)) { |
|
| 74 | - return [ |
|
| 75 | - '0 as points' /* as points */, /* where */ |
|
| 76 | - '' |
|
| 77 | - ]; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - $rechercher = false; |
|
| 82 | - |
|
| 83 | - $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND'); |
|
| 84 | - if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 85 | - $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : ''); |
|
| 86 | - $hash = substr(md5($recherche . $table), 0, 16); |
|
| 87 | - $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')"; |
|
| 88 | - $row = sql_fetsel( |
|
| 89 | - 'recherche', |
|
| 90 | - 'spip_resultats AS resultats', |
|
| 91 | - $where . " AND $where_resultat_recent", |
|
| 92 | - '', |
|
| 93 | - '', |
|
| 94 | - '0,1' |
|
| 95 | - ); |
|
| 96 | - if (!$row || (defined('_VAR_MODE') && _VAR_MODE == 'recalcul')) { |
|
| 97 | - $rechercher = true; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - // si on n'a pas encore traite les donnees dans une boucle precedente |
|
| 102 | - if ($rechercher) { |
|
| 103 | - //$tables = liste_des_champs(); |
|
| 104 | - $x = objet_type($table); |
|
| 105 | - $points = recherche_en_base( |
|
| 106 | - $recherche, |
|
| 107 | - $x, |
|
| 108 | - [ |
|
| 109 | - 'score' => true, |
|
| 110 | - 'toutvoir' => true, |
|
| 111 | - 'jointures' => true |
|
| 112 | - ], |
|
| 113 | - $serveur |
|
| 114 | - ); |
|
| 115 | - // pas de résultat, pas de point |
|
| 116 | - $points = $points[$x] ?? []; |
|
| 117 | - |
|
| 118 | - // permettre aux plugins de modifier le resultat |
|
| 119 | - $points = pipeline('prepare_recherche', [ |
|
| 120 | - 'args' => [ |
|
| 121 | - 'type' => $x, |
|
| 122 | - 'recherche' => $recherche, |
|
| 123 | - 'serveur' => $serveur, |
|
| 124 | - 'modificateurs' => $modificateurs |
|
| 125 | - ], |
|
| 126 | - 'data' => $points |
|
| 127 | - ]); |
|
| 128 | - |
|
| 129 | - // supprimer les anciens resultats de cette recherche |
|
| 130 | - // et les resultats trop vieux avec une marge |
|
| 131 | - // pas de AS resultats dans un delete (mysql) |
|
| 132 | - $whered = str_replace( |
|
| 133 | - ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'], |
|
| 134 | - ['recherche', 'table_objet', 'serveur'], |
|
| 135 | - $where |
|
| 136 | - ); |
|
| 137 | - |
|
| 138 | - sql_delete( |
|
| 139 | - 'spip_resultats', |
|
| 140 | - "NOT($where_resultat_recent) OR ($whered)" |
|
| 141 | - ); |
|
| 142 | - |
|
| 143 | - // inserer les resultats dans la table de cache des resultats |
|
| 144 | - if (is_countable($points) ? count($points) : 0) { |
|
| 145 | - $tab_couples = []; |
|
| 146 | - foreach ($points as $id => $p) { |
|
| 147 | - $tab_couples[] = [ |
|
| 148 | - 'recherche' => $hash, |
|
| 149 | - 'id' => $id, |
|
| 150 | - 'points' => $p['score'], |
|
| 151 | - 'table_objet' => $table, |
|
| 152 | - 'serveur' => $hash_serv, |
|
| 153 | - ]; |
|
| 154 | - } |
|
| 155 | - sql_insertq_multi('spip_resultats', $tab_couples, []); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 160 | - if (!$serveur) { |
|
| 161 | - $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where]; |
|
| 162 | - } else { |
|
| 163 | - if (sql_countsel('spip_resultats as resultats', $where)) { |
|
| 164 | - $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where); |
|
| 165 | - } |
|
| 166 | - $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - return $cache[$serveur][$table][$recherche]; |
|
| 58 | + $where = null; |
|
| 59 | + $rows = null; |
|
| 60 | + static $cache = []; |
|
| 61 | + $delai_fraicheur = min( |
|
| 62 | + \_DELAI_CACHE_resultats, |
|
| 63 | + time() - ($GLOBALS['meta']['derniere_modif'] ?? 0) |
|
| 64 | + ); |
|
| 65 | + |
|
| 66 | + // si recherche n'est pas dans le contexte, on va prendre en globals |
|
| 67 | + // ca permet de faire des inclure simple. |
|
| 68 | + if (!isset($recherche) && isset($GLOBALS['recherche'])) { |
|
| 69 | + $recherche = $GLOBALS['recherche']; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // traiter le cas {recherche?} |
|
| 73 | + if ($cond && !strlen($recherche)) { |
|
| 74 | + return [ |
|
| 75 | + '0 as points' /* as points */, /* where */ |
|
| 76 | + '' |
|
| 77 | + ]; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + $rechercher = false; |
|
| 82 | + |
|
| 83 | + $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND'); |
|
| 84 | + if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 85 | + $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : ''); |
|
| 86 | + $hash = substr(md5($recherche . $table), 0, 16); |
|
| 87 | + $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')"; |
|
| 88 | + $row = sql_fetsel( |
|
| 89 | + 'recherche', |
|
| 90 | + 'spip_resultats AS resultats', |
|
| 91 | + $where . " AND $where_resultat_recent", |
|
| 92 | + '', |
|
| 93 | + '', |
|
| 94 | + '0,1' |
|
| 95 | + ); |
|
| 96 | + if (!$row || (defined('_VAR_MODE') && _VAR_MODE == 'recalcul')) { |
|
| 97 | + $rechercher = true; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + // si on n'a pas encore traite les donnees dans une boucle precedente |
|
| 102 | + if ($rechercher) { |
|
| 103 | + //$tables = liste_des_champs(); |
|
| 104 | + $x = objet_type($table); |
|
| 105 | + $points = recherche_en_base( |
|
| 106 | + $recherche, |
|
| 107 | + $x, |
|
| 108 | + [ |
|
| 109 | + 'score' => true, |
|
| 110 | + 'toutvoir' => true, |
|
| 111 | + 'jointures' => true |
|
| 112 | + ], |
|
| 113 | + $serveur |
|
| 114 | + ); |
|
| 115 | + // pas de résultat, pas de point |
|
| 116 | + $points = $points[$x] ?? []; |
|
| 117 | + |
|
| 118 | + // permettre aux plugins de modifier le resultat |
|
| 119 | + $points = pipeline('prepare_recherche', [ |
|
| 120 | + 'args' => [ |
|
| 121 | + 'type' => $x, |
|
| 122 | + 'recherche' => $recherche, |
|
| 123 | + 'serveur' => $serveur, |
|
| 124 | + 'modificateurs' => $modificateurs |
|
| 125 | + ], |
|
| 126 | + 'data' => $points |
|
| 127 | + ]); |
|
| 128 | + |
|
| 129 | + // supprimer les anciens resultats de cette recherche |
|
| 130 | + // et les resultats trop vieux avec une marge |
|
| 131 | + // pas de AS resultats dans un delete (mysql) |
|
| 132 | + $whered = str_replace( |
|
| 133 | + ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'], |
|
| 134 | + ['recherche', 'table_objet', 'serveur'], |
|
| 135 | + $where |
|
| 136 | + ); |
|
| 137 | + |
|
| 138 | + sql_delete( |
|
| 139 | + 'spip_resultats', |
|
| 140 | + "NOT($where_resultat_recent) OR ($whered)" |
|
| 141 | + ); |
|
| 142 | + |
|
| 143 | + // inserer les resultats dans la table de cache des resultats |
|
| 144 | + if (is_countable($points) ? count($points) : 0) { |
|
| 145 | + $tab_couples = []; |
|
| 146 | + foreach ($points as $id => $p) { |
|
| 147 | + $tab_couples[] = [ |
|
| 148 | + 'recherche' => $hash, |
|
| 149 | + 'id' => $id, |
|
| 150 | + 'points' => $p['score'], |
|
| 151 | + 'table_objet' => $table, |
|
| 152 | + 'serveur' => $hash_serv, |
|
| 153 | + ]; |
|
| 154 | + } |
|
| 155 | + sql_insertq_multi('spip_resultats', $tab_couples, []); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 160 | + if (!$serveur) { |
|
| 161 | + $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where]; |
|
| 162 | + } else { |
|
| 163 | + if (sql_countsel('spip_resultats as resultats', $where)) { |
|
| 164 | + $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where); |
|
| 165 | + } |
|
| 166 | + $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + return $cache[$serveur][$table][$recherche]; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | |
@@ -183,22 +183,22 @@ discard block |
||
| 183 | 183 | * @return array |
| 184 | 184 | */ |
| 185 | 185 | function generer_select_where_explicites($table, $primary, $rows, $serveur) { |
| 186 | - # calculer le {id_article IN()} et le {... as points} |
|
| 187 | - if ($rows === []) { |
|
| 188 | - return ["''", '0=1']; |
|
| 189 | - } else { |
|
| 190 | - $listes_ids = []; |
|
| 191 | - $select = '0'; |
|
| 192 | - foreach ($rows as $r) { |
|
| 193 | - $listes_ids[$r['points']][] = $r['id']; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - foreach ($listes_ids as $p => $ids) { |
|
| 197 | - $select .= "+$p*(" . |
|
| 198 | - sql_in("$table.$primary", $ids, '', $serveur) |
|
| 199 | - . ') '; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)]; |
|
| 203 | - } |
|
| 186 | + # calculer le {id_article IN()} et le {... as points} |
|
| 187 | + if ($rows === []) { |
|
| 188 | + return ["''", '0=1']; |
|
| 189 | + } else { |
|
| 190 | + $listes_ids = []; |
|
| 191 | + $select = '0'; |
|
| 192 | + foreach ($rows as $r) { |
|
| 193 | + $listes_ids[$r['points']][] = $r['id']; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + foreach ($listes_ids as $p => $ids) { |
|
| 197 | + $select .= "+$p*(" . |
|
| 198 | + sql_in("$table.$primary", $ids, '', $serveur) |
|
| 199 | + . ') '; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)]; |
|
| 203 | + } |
|
| 204 | 204 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $titre = '<title>[' |
| 95 | 95 | . $nom_site_spip |
| 96 | - . '] ' . $match |
|
| 96 | + . '] '.$match |
|
| 97 | 97 | . '</title>'; |
| 98 | 98 | |
| 99 | 99 | $texte = substr_replace($texte, $titre, $p + 6, 0); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $flux['data']['texte'] = pipeline( |
| 156 | 156 | 'affiche_droite', |
| 157 | 157 | ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
| 158 | - ) . liste_objets_bloques( |
|
| 158 | + ).liste_objets_bloques( |
|
| 159 | 159 | $exec, |
| 160 | 160 | $flux['args']['contexte'] |
| 161 | 161 | ); |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
| 191 | 191 | 'prive/objets/editer/traductions', |
| 192 | 192 | ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
| 193 | - ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 193 | + ).'<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 194 | 194 | $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
| 195 | 195 | 'args' => [ |
| 196 | 196 | 'contexte' => $flux['args']['contexte'], |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | $full_marqueur = "$ouvrir$marqueur$fermer"; |
| 259 | 259 | |
| 260 | 260 | // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
| 261 | - if ($marqueur_pos === false) { |
|
| 261 | + if ($marqueur_pos === false) { |
|
| 262 | 262 | $texte = preg_replace( |
| 263 | 263 | ",$inserer_avant,", |
| 264 | 264 | "$full_marqueur\\0", |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | if ($res) { |
| 308 | - $flux['data'] = $res . $flux['data']; |
|
| 308 | + $flux['data'] = $res.$flux['data']; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | return $flux; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Pipelines |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -34,40 +34,40 @@ discard block |
||
| 34 | 34 | * @return string Contenu complété des scripts javascripts, dont jQuery |
| 35 | 35 | **/ |
| 36 | 36 | function f_jQuery_prive($texte) { |
| 37 | - $x = ''; |
|
| 38 | - $jquery_plugins = pipeline( |
|
| 39 | - 'jquery_plugins', |
|
| 40 | - [ |
|
| 41 | - 'prive/javascript/jquery.js', |
|
| 42 | - 'prive/javascript/jquery.form.js', |
|
| 43 | - 'prive/javascript/jquery.autosave.js', |
|
| 44 | - 'prive/javascript/jquery.placeholder-label.js', |
|
| 45 | - 'prive/javascript/ajaxCallback.js', |
|
| 46 | - 'prive/javascript/js.cookie.js', |
|
| 47 | - 'prive/javascript/spip_barre.js', |
|
| 48 | - ] |
|
| 49 | - ); |
|
| 50 | - foreach (array_unique($jquery_plugins) as $script) { |
|
| 51 | - $script = supprimer_timestamp($script); |
|
| 52 | - if ( |
|
| 53 | - str_starts_with($script, _DIR_VAR) && file_exists($script) |
|
| 54 | - || ($script = find_in_path($script)) |
|
| 55 | - ) { |
|
| 56 | - $script = timestamp($script); |
|
| 57 | - $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - // inserer avant le premier script externe ou a la fin |
|
| 61 | - if ( |
|
| 62 | - preg_match(',<script[^><]*src=,', $texte, $match) |
|
| 63 | - && ($p = strpos($texte, (string) $match[0])) |
|
| 64 | - ) { |
|
| 65 | - $texte = substr_replace($texte, $x, $p, 0); |
|
| 66 | - } else { |
|
| 67 | - $texte .= $x; |
|
| 68 | - } |
|
| 37 | + $x = ''; |
|
| 38 | + $jquery_plugins = pipeline( |
|
| 39 | + 'jquery_plugins', |
|
| 40 | + [ |
|
| 41 | + 'prive/javascript/jquery.js', |
|
| 42 | + 'prive/javascript/jquery.form.js', |
|
| 43 | + 'prive/javascript/jquery.autosave.js', |
|
| 44 | + 'prive/javascript/jquery.placeholder-label.js', |
|
| 45 | + 'prive/javascript/ajaxCallback.js', |
|
| 46 | + 'prive/javascript/js.cookie.js', |
|
| 47 | + 'prive/javascript/spip_barre.js', |
|
| 48 | + ] |
|
| 49 | + ); |
|
| 50 | + foreach (array_unique($jquery_plugins) as $script) { |
|
| 51 | + $script = supprimer_timestamp($script); |
|
| 52 | + if ( |
|
| 53 | + str_starts_with($script, _DIR_VAR) && file_exists($script) |
|
| 54 | + || ($script = find_in_path($script)) |
|
| 55 | + ) { |
|
| 56 | + $script = timestamp($script); |
|
| 57 | + $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + // inserer avant le premier script externe ou a la fin |
|
| 61 | + if ( |
|
| 62 | + preg_match(',<script[^><]*src=,', $texte, $match) |
|
| 63 | + && ($p = strpos($texte, (string) $match[0])) |
|
| 64 | + ) { |
|
| 65 | + $texte = substr_replace($texte, $x, $p, 0); |
|
| 66 | + } else { |
|
| 67 | + $texte .= $x; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return $texte; |
|
| 70 | + return $texte; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
@@ -80,40 +80,40 @@ discard block |
||
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | 82 | function affichage_final_prive_title_auto($texte) { |
| 83 | - if ( |
|
| 84 | - !str_contains($texte, '<title>') |
|
| 85 | - && (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) || preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 86 | - && ($match = textebrut(trim($match[1]))) |
|
| 87 | - && ($p = strpos($texte, '<head>')) !== false |
|
| 88 | - ) { |
|
| 89 | - if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 90 | - $nom_site_spip = _T('info_mon_site_spip'); |
|
| 91 | - } |
|
| 83 | + if ( |
|
| 84 | + !str_contains($texte, '<title>') |
|
| 85 | + && (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) || preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 86 | + && ($match = textebrut(trim($match[1]))) |
|
| 87 | + && ($p = strpos($texte, '<head>')) !== false |
|
| 88 | + ) { |
|
| 89 | + if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 90 | + $nom_site_spip = _T('info_mon_site_spip'); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $titre = '<title>[' |
|
| 94 | - . $nom_site_spip |
|
| 95 | - . '] ' . $match |
|
| 96 | - . '</title>'; |
|
| 93 | + $titre = '<title>[' |
|
| 94 | + . $nom_site_spip |
|
| 95 | + . '] ' . $match |
|
| 96 | + . '</title>'; |
|
| 97 | 97 | |
| 98 | - $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 99 | - } |
|
| 98 | + $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - return $texte; |
|
| 101 | + return $texte; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | // Fonction standard pour le pipeline 'boite_infos' |
| 106 | 106 | function f_boite_infos($flux) { |
| 107 | - $args = $flux['args']; |
|
| 108 | - $type = $args['type']; |
|
| 109 | - unset($args['row']); |
|
| 110 | - if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 111 | - $type = 'objet'; |
|
| 112 | - } |
|
| 113 | - $args['espace_prive'] = 1; |
|
| 114 | - $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 107 | + $args = $flux['args']; |
|
| 108 | + $type = $args['type']; |
|
| 109 | + unset($args['row']); |
|
| 110 | + if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 111 | + $type = 'objet'; |
|
| 112 | + } |
|
| 113 | + $args['espace_prive'] = 1; |
|
| 114 | + $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 115 | 115 | |
| 116 | - return $flux; |
|
| 116 | + return $flux; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -132,97 +132,97 @@ discard block |
||
| 132 | 132 | * @return array Données du pipeline |
| 133 | 133 | */ |
| 134 | 134 | function f_afficher_blocs_ecrire($flux) { |
| 135 | - static $o = []; |
|
| 136 | - if (is_string($fond = $flux['args']['fond'])) { |
|
| 137 | - $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 138 | - if (!isset($o[$exec])) { |
|
| 139 | - $o[$exec] = trouver_objet_exec($exec); |
|
| 140 | - } |
|
| 141 | - // cas particulier |
|
| 142 | - if ($exec == 'infos_perso') { |
|
| 143 | - $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 144 | - } |
|
| 145 | - $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 146 | - if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 147 | - $flux['data']['texte'] = pipeline( |
|
| 148 | - 'affiche_gauche', |
|
| 149 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 150 | - ); |
|
| 151 | - } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 152 | - include_spip('inc/presentation_mini'); |
|
| 153 | - $flux['data']['texte'] = pipeline( |
|
| 154 | - 'affiche_droite', |
|
| 155 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 156 | - ) . liste_objets_bloques( |
|
| 157 | - $exec, |
|
| 158 | - $flux['args']['contexte'] |
|
| 159 | - ); |
|
| 160 | - } elseif ($fond == "prive/squelettes/hierarchie/$typepage" && $o[$exec]) { |
|
| 161 | - // id non defini sur les formulaire de nouveaux objets |
|
| 162 | - $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 163 | - $flux['data']['texte'] = pipeline( |
|
| 164 | - 'affiche_hierarchie', |
|
| 165 | - ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 166 | - ); |
|
| 167 | - } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 168 | - // Préparation du marqueur affiche_milieu |
|
| 169 | - // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 170 | - $est_page_objet = !empty($o[$exec]['type']); |
|
| 171 | - $est_en_edition = (isset($o[$exec]['edition']) && $o[$exec]['edition'] === true); |
|
| 172 | - $encapsuler_milieu = ($est_page_objet && !$est_en_edition); |
|
| 173 | - $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 174 | - $flux['data']['texte'], |
|
| 175 | - '<!--affiche_milieu-->', |
|
| 176 | - '<div id=["\']wysiwyg', |
|
| 177 | - $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 178 | - $encapsuler_milieu ? '</div>' : '' |
|
| 179 | - ); |
|
| 180 | - if ( |
|
| 181 | - $o[$exec] |
|
| 182 | - && ($objet = $o[$exec]['type']) |
|
| 183 | - && $o[$exec]['edition'] == false |
|
| 184 | - && isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 185 | - && ($id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])) |
|
| 186 | - ) { |
|
| 187 | - // inserer le formulaire de traduction |
|
| 188 | - $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 189 | - 'prive/objets/editer/traductions', |
|
| 190 | - ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 191 | - ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 192 | - $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 193 | - 'args' => [ |
|
| 194 | - 'contexte' => $flux['args']['contexte'], |
|
| 195 | - 'type' => $objet, |
|
| 196 | - 'id' => $id |
|
| 197 | - ], |
|
| 198 | - 'data' => $flux['data']['texte'] |
|
| 199 | - ]); |
|
| 200 | - } |
|
| 201 | - $flux['data']['texte'] = pipeline( |
|
| 202 | - 'affiche_milieu', |
|
| 203 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 204 | - ); |
|
| 205 | - } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 206 | - $flux['data']['texte'] = pipeline( |
|
| 207 | - 'affiche_pied', |
|
| 208 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 209 | - ); |
|
| 210 | - } elseif ( |
|
| 211 | - str_starts_with($fond, 'prive/objets/contenu/') |
|
| 212 | - && ($objet = basename($fond)) |
|
| 213 | - && $objet == substr($fond, 21) |
|
| 214 | - && isset($o[$objet]) |
|
| 215 | - && $o[$objet] |
|
| 216 | - ) { |
|
| 217 | - $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 218 | - $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 219 | - 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 220 | - 'data' => $flux['data']['texte'] |
|
| 221 | - ]); |
|
| 222 | - } |
|
| 223 | - } |
|
| 135 | + static $o = []; |
|
| 136 | + if (is_string($fond = $flux['args']['fond'])) { |
|
| 137 | + $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 138 | + if (!isset($o[$exec])) { |
|
| 139 | + $o[$exec] = trouver_objet_exec($exec); |
|
| 140 | + } |
|
| 141 | + // cas particulier |
|
| 142 | + if ($exec == 'infos_perso') { |
|
| 143 | + $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 144 | + } |
|
| 145 | + $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 146 | + if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 147 | + $flux['data']['texte'] = pipeline( |
|
| 148 | + 'affiche_gauche', |
|
| 149 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 150 | + ); |
|
| 151 | + } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 152 | + include_spip('inc/presentation_mini'); |
|
| 153 | + $flux['data']['texte'] = pipeline( |
|
| 154 | + 'affiche_droite', |
|
| 155 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 156 | + ) . liste_objets_bloques( |
|
| 157 | + $exec, |
|
| 158 | + $flux['args']['contexte'] |
|
| 159 | + ); |
|
| 160 | + } elseif ($fond == "prive/squelettes/hierarchie/$typepage" && $o[$exec]) { |
|
| 161 | + // id non defini sur les formulaire de nouveaux objets |
|
| 162 | + $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 163 | + $flux['data']['texte'] = pipeline( |
|
| 164 | + 'affiche_hierarchie', |
|
| 165 | + ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 166 | + ); |
|
| 167 | + } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 168 | + // Préparation du marqueur affiche_milieu |
|
| 169 | + // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 170 | + $est_page_objet = !empty($o[$exec]['type']); |
|
| 171 | + $est_en_edition = (isset($o[$exec]['edition']) && $o[$exec]['edition'] === true); |
|
| 172 | + $encapsuler_milieu = ($est_page_objet && !$est_en_edition); |
|
| 173 | + $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 174 | + $flux['data']['texte'], |
|
| 175 | + '<!--affiche_milieu-->', |
|
| 176 | + '<div id=["\']wysiwyg', |
|
| 177 | + $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 178 | + $encapsuler_milieu ? '</div>' : '' |
|
| 179 | + ); |
|
| 180 | + if ( |
|
| 181 | + $o[$exec] |
|
| 182 | + && ($objet = $o[$exec]['type']) |
|
| 183 | + && $o[$exec]['edition'] == false |
|
| 184 | + && isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 185 | + && ($id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']])) |
|
| 186 | + ) { |
|
| 187 | + // inserer le formulaire de traduction |
|
| 188 | + $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 189 | + 'prive/objets/editer/traductions', |
|
| 190 | + ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 191 | + ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 192 | + $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 193 | + 'args' => [ |
|
| 194 | + 'contexte' => $flux['args']['contexte'], |
|
| 195 | + 'type' => $objet, |
|
| 196 | + 'id' => $id |
|
| 197 | + ], |
|
| 198 | + 'data' => $flux['data']['texte'] |
|
| 199 | + ]); |
|
| 200 | + } |
|
| 201 | + $flux['data']['texte'] = pipeline( |
|
| 202 | + 'affiche_milieu', |
|
| 203 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 204 | + ); |
|
| 205 | + } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 206 | + $flux['data']['texte'] = pipeline( |
|
| 207 | + 'affiche_pied', |
|
| 208 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 209 | + ); |
|
| 210 | + } elseif ( |
|
| 211 | + str_starts_with($fond, 'prive/objets/contenu/') |
|
| 212 | + && ($objet = basename($fond)) |
|
| 213 | + && $objet == substr($fond, 21) |
|
| 214 | + && isset($o[$objet]) |
|
| 215 | + && $o[$objet] |
|
| 216 | + ) { |
|
| 217 | + $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 218 | + $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 219 | + 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 220 | + 'data' => $flux['data']['texte'] |
|
| 221 | + ]); |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - return $flux; |
|
| 225 | + return $flux; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -250,36 +250,36 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string { |
| 252 | 252 | |
| 253 | - if ($texte) { |
|
| 254 | - $encapsuler = $ouvrir && $fermer; |
|
| 255 | - $marqueur_pos = strpos($texte, $marqueur); |
|
| 256 | - $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 253 | + if ($texte) { |
|
| 254 | + $encapsuler = $ouvrir && $fermer; |
|
| 255 | + $marqueur_pos = strpos($texte, $marqueur); |
|
| 256 | + $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 257 | 257 | |
| 258 | - // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 259 | - if ($marqueur_pos === false) { |
|
| 260 | - $texte = preg_replace( |
|
| 261 | - ",$inserer_avant,", |
|
| 262 | - "$full_marqueur\\0", |
|
| 263 | - $texte |
|
| 264 | - ); |
|
| 265 | - // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 266 | - // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 267 | - // Il ne faut donc aucun espace blanc en trop. |
|
| 268 | - } elseif ( |
|
| 269 | - $marqueur_pos !== false |
|
| 270 | - && $encapsuler |
|
| 271 | - && substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 272 | - ) { |
|
| 273 | - $texte = substr_replace( |
|
| 274 | - $texte, |
|
| 275 | - $full_marqueur, |
|
| 276 | - $marqueur_pos, |
|
| 277 | - strlen($marqueur) |
|
| 278 | - ); |
|
| 279 | - } |
|
| 280 | - } |
|
| 258 | + // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 259 | + if ($marqueur_pos === false) { |
|
| 260 | + $texte = preg_replace( |
|
| 261 | + ",$inserer_avant,", |
|
| 262 | + "$full_marqueur\\0", |
|
| 263 | + $texte |
|
| 264 | + ); |
|
| 265 | + // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 266 | + // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 267 | + // Il ne faut donc aucun espace blanc en trop. |
|
| 268 | + } elseif ( |
|
| 269 | + $marqueur_pos !== false |
|
| 270 | + && $encapsuler |
|
| 271 | + && substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 272 | + ) { |
|
| 273 | + $texte = substr_replace( |
|
| 274 | + $texte, |
|
| 275 | + $full_marqueur, |
|
| 276 | + $marqueur_pos, |
|
| 277 | + strlen($marqueur) |
|
| 278 | + ); |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - return $texte; |
|
| 282 | + return $texte; |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -290,23 +290,23 @@ discard block |
||
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | 292 | function f_queue_affiche_milieu($flux) { |
| 293 | - $args = $flux['args']; |
|
| 294 | - $res = ''; |
|
| 295 | - foreach ($args as $key => $arg) { |
|
| 296 | - if (preg_match(',^id_,', $key) && is_numeric($arg) && ($arg = intval($arg))) { |
|
| 297 | - $objet = preg_replace(',^id_,', '', $key); |
|
| 298 | - $res .= recuperer_fond( |
|
| 299 | - 'modeles/object_jobs_list', |
|
| 300 | - ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 301 | - ['ajax' => true] |
|
| 302 | - ); |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - if ($res) { |
|
| 306 | - $flux['data'] = $res . $flux['data']; |
|
| 307 | - } |
|
| 293 | + $args = $flux['args']; |
|
| 294 | + $res = ''; |
|
| 295 | + foreach ($args as $key => $arg) { |
|
| 296 | + if (preg_match(',^id_,', $key) && is_numeric($arg) && ($arg = intval($arg))) { |
|
| 297 | + $objet = preg_replace(',^id_,', '', $key); |
|
| 298 | + $res .= recuperer_fond( |
|
| 299 | + 'modeles/object_jobs_list', |
|
| 300 | + ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 301 | + ['ajax' => true] |
|
| 302 | + ); |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + if ($res) { |
|
| 306 | + $flux['data'] = $res . $flux['data']; |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - return $flux; |
|
| 309 | + return $flux; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -320,39 +320,39 @@ discard block |
||
| 320 | 320 | * @return array|bool |
| 321 | 321 | */ |
| 322 | 322 | function trouver_objet_exec(?string $exec) { |
| 323 | - static $objet_exec = []; |
|
| 324 | - if (!$exec) { |
|
| 325 | - return false; |
|
| 326 | - } |
|
| 327 | - // cas particulier |
|
| 328 | - if ($exec === 'infos_perso') { |
|
| 329 | - $exec = 'auteur'; |
|
| 330 | - set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 331 | - } |
|
| 332 | - if (!isset($objet_exec[$exec])) { |
|
| 333 | - $objet_exec[$exec] = false; |
|
| 334 | - $infos = lister_tables_objets_sql(); |
|
| 335 | - foreach ($infos as $t => $info) { |
|
| 336 | - if ($exec === $info['url_edit'] && $info['editable']) { |
|
| 337 | - return $objet_exec[$exec] = [ |
|
| 338 | - 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 339 | - 'table_objet_sql' => $t, |
|
| 340 | - 'table' => $info['table_objet'], |
|
| 341 | - 'type' => $info['type'], |
|
| 342 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 343 | - ]; |
|
| 344 | - } |
|
| 345 | - if ($exec === $info['url_voir']) { |
|
| 346 | - return $objet_exec[$exec] = [ |
|
| 347 | - 'edition' => false, |
|
| 348 | - 'table_objet_sql' => $t, |
|
| 349 | - 'table' => $info['table_objet'], |
|
| 350 | - 'type' => $info['type'], |
|
| 351 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 352 | - ]; |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - } |
|
| 323 | + static $objet_exec = []; |
|
| 324 | + if (!$exec) { |
|
| 325 | + return false; |
|
| 326 | + } |
|
| 327 | + // cas particulier |
|
| 328 | + if ($exec === 'infos_perso') { |
|
| 329 | + $exec = 'auteur'; |
|
| 330 | + set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 331 | + } |
|
| 332 | + if (!isset($objet_exec[$exec])) { |
|
| 333 | + $objet_exec[$exec] = false; |
|
| 334 | + $infos = lister_tables_objets_sql(); |
|
| 335 | + foreach ($infos as $t => $info) { |
|
| 336 | + if ($exec === $info['url_edit'] && $info['editable']) { |
|
| 337 | + return $objet_exec[$exec] = [ |
|
| 338 | + 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 339 | + 'table_objet_sql' => $t, |
|
| 340 | + 'table' => $info['table_objet'], |
|
| 341 | + 'type' => $info['type'], |
|
| 342 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 343 | + ]; |
|
| 344 | + } |
|
| 345 | + if ($exec === $info['url_voir']) { |
|
| 346 | + return $objet_exec[$exec] = [ |
|
| 347 | + 'edition' => false, |
|
| 348 | + 'table_objet_sql' => $t, |
|
| 349 | + 'table' => $info['table_objet'], |
|
| 350 | + 'type' => $info['type'], |
|
| 351 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 352 | + ]; |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - return $objet_exec[$exec]; |
|
| 357 | + return $objet_exec[$exec]; |
|
| 358 | 358 | } |
@@ -341,8 +341,7 @@ |
||
| 341 | 341 | ) { |
| 342 | 342 | if ($use_copy) { |
| 343 | 343 | @copy($fichier_tmp, $fichier); |
| 344 | - } |
|
| 345 | - else { |
|
| 344 | + } else { |
|
| 346 | 345 | @rename($fichier_tmp, $fichier); |
| 347 | 346 | } |
| 348 | 347 | // eviter que PHP ne reserve le vieux timestamp |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if (!defined('_TEST_FILE_EXISTS')) { |
| 23 | - /** Permettre d'éviter des tests file_exists sur certains hébergeurs */ |
|
| 24 | - define('_TEST_FILE_EXISTS', preg_match(',(online|free)[.]fr$,', $_ENV['HTTP_HOST'] ?? '')); |
|
| 23 | + /** Permettre d'éviter des tests file_exists sur certains hébergeurs */ |
|
| 24 | + define('_TEST_FILE_EXISTS', preg_match(',(online|free)[.]fr$,', $_ENV['HTTP_HOST'] ?? '')); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | #define('_SPIP_LOCK_MODE',0); // ne pas utiliser de lock (deconseille) |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | #define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip |
| 30 | 30 | |
| 31 | 31 | if (_SPIP_LOCK_MODE == 2) { |
| 32 | - include_spip('inc/nfslock'); |
|
| 32 | + include_spip('inc/nfslock'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $GLOBALS['liste_verrous'] = []; |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | * Ressource sur le fichier ouvert, sinon false. |
| 53 | 53 | **/ |
| 54 | 54 | function spip_fopen_lock($fichier, $mode, $verrou) { |
| 55 | - if (_SPIP_LOCK_MODE == 1) { |
|
| 56 | - if ($fl = @fopen($fichier, $mode)) { |
|
| 57 | - // verrou |
|
| 58 | - @flock($fl, $verrou); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - return $fl; |
|
| 62 | - } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 63 | - if (($verrou = spip_nfslock($fichier)) && ($fl = @fopen($fichier, $mode))) { |
|
| 64 | - $GLOBALS['liste_verrous'][$fl] = [$fichier, $verrou]; |
|
| 65 | - |
|
| 66 | - return $fl; |
|
| 67 | - } else { |
|
| 68 | - return false; |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return @fopen($fichier, $mode); |
|
| 55 | + if (_SPIP_LOCK_MODE == 1) { |
|
| 56 | + if ($fl = @fopen($fichier, $mode)) { |
|
| 57 | + // verrou |
|
| 58 | + @flock($fl, $verrou); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + return $fl; |
|
| 62 | + } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 63 | + if (($verrou = spip_nfslock($fichier)) && ($fl = @fopen($fichier, $mode))) { |
|
| 64 | + $GLOBALS['liste_verrous'][$fl] = [$fichier, $verrou]; |
|
| 65 | + |
|
| 66 | + return $fl; |
|
| 67 | + } else { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return @fopen($fichier, $mode); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | * true si succès, false sinon. |
| 85 | 85 | **/ |
| 86 | 86 | function spip_fclose_unlock($handle) { |
| 87 | - if (_SPIP_LOCK_MODE == 1) { |
|
| 88 | - @flock($handle, LOCK_UN); |
|
| 89 | - } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 90 | - spip_nfsunlock(reset($GLOBALS['liste_verrous'][$handle]), end($GLOBALS['liste_verrous'][$handle])); |
|
| 91 | - unset($GLOBALS['liste_verrous'][$handle]); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return @fclose($handle); |
|
| 87 | + if (_SPIP_LOCK_MODE == 1) { |
|
| 88 | + @flock($handle, LOCK_UN); |
|
| 89 | + } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 90 | + spip_nfsunlock(reset($GLOBALS['liste_verrous'][$handle]), end($GLOBALS['liste_verrous'][$handle])); |
|
| 91 | + unset($GLOBALS['liste_verrous'][$handle]); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return @fclose($handle); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
@@ -105,23 +105,23 @@ discard block |
||
| 105 | 105 | * Contenu du fichier |
| 106 | 106 | **/ |
| 107 | 107 | function spip_file_get_contents($fichier) { |
| 108 | - if (!str_ends_with($fichier, '.gz')) { |
|
| 109 | - if (function_exists('file_get_contents')) { |
|
| 110 | - // quand on est sous windows on ne sait pas si file_get_contents marche |
|
| 111 | - // on essaye : si ca retourne du contenu alors c'est bon |
|
| 112 | - // sinon on fait un file() pour avoir le coeur net |
|
| 113 | - $contenu = @file_get_contents($fichier); |
|
| 114 | - if (!$contenu && _OS_SERVEUR == 'windows') { |
|
| 115 | - $contenu = @file($fichier); |
|
| 116 | - } |
|
| 117 | - } else { |
|
| 118 | - $contenu = @file($fichier); |
|
| 119 | - } |
|
| 120 | - } else { |
|
| 121 | - $contenu = @gzfile($fichier); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return is_array($contenu) ? implode('', $contenu) : (string)$contenu; |
|
| 108 | + if (!str_ends_with($fichier, '.gz')) { |
|
| 109 | + if (function_exists('file_get_contents')) { |
|
| 110 | + // quand on est sous windows on ne sait pas si file_get_contents marche |
|
| 111 | + // on essaye : si ca retourne du contenu alors c'est bon |
|
| 112 | + // sinon on fait un file() pour avoir le coeur net |
|
| 113 | + $contenu = @file_get_contents($fichier); |
|
| 114 | + if (!$contenu && _OS_SERVEUR == 'windows') { |
|
| 115 | + $contenu = @file($fichier); |
|
| 116 | + } |
|
| 117 | + } else { |
|
| 118 | + $contenu = @file($fichier); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + $contenu = @gzfile($fichier); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return is_array($contenu) ? implode('', $contenu) : (string)$contenu; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -146,48 +146,48 @@ discard block |
||
| 146 | 146 | * true si l'opération a réussie, false sinon. |
| 147 | 147 | **/ |
| 148 | 148 | function lire_fichier($fichier, &$contenu, $options = []) { |
| 149 | - $contenu = ''; |
|
| 150 | - // inutile car si le fichier n'existe pas, le lock va renvoyer false juste apres |
|
| 151 | - // economisons donc les acces disque, sauf chez free qui rale pour un rien |
|
| 152 | - if (_TEST_FILE_EXISTS && !@file_exists($fichier)) { |
|
| 153 | - return false; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - #spip_timer('lire_fichier'); |
|
| 157 | - |
|
| 158 | - // pas de @ sur spip_fopen_lock qui est silencieux de toute facon |
|
| 159 | - if ($fl = spip_fopen_lock($fichier, 'r', LOCK_SH)) { |
|
| 160 | - // lire le fichier avant tout |
|
| 161 | - $contenu = spip_file_get_contents($fichier); |
|
| 162 | - |
|
| 163 | - // le fichier a-t-il ete supprime par le locker ? |
|
| 164 | - // on ne verifie que si la tentative de lecture a echoue |
|
| 165 | - // pour discriminer un contenu vide d'un fichier absent |
|
| 166 | - // et eviter un acces disque |
|
| 167 | - if (!$contenu && !@file_exists($fichier)) { |
|
| 168 | - spip_fclose_unlock($fl); |
|
| 169 | - |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - // liberer le verrou |
|
| 174 | - spip_fclose_unlock($fl); |
|
| 175 | - |
|
| 176 | - // Verifications |
|
| 177 | - $ok = true; |
|
| 178 | - if (isset($options['phpcheck']) && $options['phpcheck'] == 'oui') { |
|
| 179 | - $ok &= (preg_match(",[?]>\n?$,", $contenu)); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - #spip_logger()->info("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 183 | - if (!$ok) { |
|
| 184 | - spip_logger()->info("echec lecture $fichier"); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - return $ok; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - return false; |
|
| 149 | + $contenu = ''; |
|
| 150 | + // inutile car si le fichier n'existe pas, le lock va renvoyer false juste apres |
|
| 151 | + // economisons donc les acces disque, sauf chez free qui rale pour un rien |
|
| 152 | + if (_TEST_FILE_EXISTS && !@file_exists($fichier)) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + #spip_timer('lire_fichier'); |
|
| 157 | + |
|
| 158 | + // pas de @ sur spip_fopen_lock qui est silencieux de toute facon |
|
| 159 | + if ($fl = spip_fopen_lock($fichier, 'r', LOCK_SH)) { |
|
| 160 | + // lire le fichier avant tout |
|
| 161 | + $contenu = spip_file_get_contents($fichier); |
|
| 162 | + |
|
| 163 | + // le fichier a-t-il ete supprime par le locker ? |
|
| 164 | + // on ne verifie que si la tentative de lecture a echoue |
|
| 165 | + // pour discriminer un contenu vide d'un fichier absent |
|
| 166 | + // et eviter un acces disque |
|
| 167 | + if (!$contenu && !@file_exists($fichier)) { |
|
| 168 | + spip_fclose_unlock($fl); |
|
| 169 | + |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + // liberer le verrou |
|
| 174 | + spip_fclose_unlock($fl); |
|
| 175 | + |
|
| 176 | + // Verifications |
|
| 177 | + $ok = true; |
|
| 178 | + if (isset($options['phpcheck']) && $options['phpcheck'] == 'oui') { |
|
| 179 | + $ok &= (preg_match(",[?]>\n?$,", $contenu)); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + #spip_logger()->info("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 183 | + if (!$ok) { |
|
| 184 | + spip_logger()->info("echec lecture $fichier"); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + return $ok; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + return false; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -215,92 +215,92 @@ discard block |
||
| 215 | 215 | **/ |
| 216 | 216 | function ecrire_fichier($fichier, $contenu, $ignorer_echec = false, $truncate = true) { |
| 217 | 217 | |
| 218 | - #spip_timer('ecrire_fichier'); |
|
| 219 | - |
|
| 220 | - // verrouiller le fichier destination |
|
| 221 | - if ($fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 222 | - // ecrire les donnees, compressees le cas echeant |
|
| 223 | - // (on ouvre un nouveau pointeur sur le fichier, ce qui a l'avantage |
|
| 224 | - // de le recreer si le locker qui nous precede l'avait supprime...) |
|
| 225 | - if (str_ends_with($fichier, '.gz')) { |
|
| 226 | - $contenu = gzencode($contenu); |
|
| 227 | - } |
|
| 228 | - // si c'est une ecriture avec troncation , on fait plutot une ecriture complete a cote suivie unlink+rename |
|
| 229 | - // pour etre sur d'avoir une operation atomique |
|
| 230 | - // y compris en NFS : http://www.ietf.org/rfc/rfc1094.txt |
|
| 231 | - // sauf sous wintruc ou ca ne marche pas |
|
| 232 | - $ok = false; |
|
| 233 | - if ($truncate && _OS_SERVEUR != 'windows') { |
|
| 234 | - if (!function_exists('creer_uniqid')) { |
|
| 235 | - include_spip('inc/acces'); |
|
| 236 | - } |
|
| 237 | - $id = creer_uniqid(); |
|
| 238 | - // on ouvre un pointeur sur un fichier temporaire en ecriture +raz |
|
| 239 | - if ($fp2 = spip_fopen_lock("$fichier.$id", 'w', LOCK_EX)) { |
|
| 240 | - $s = @fwrite($fp2, (string) $contenu, $a = strlen((string) $contenu)); |
|
| 241 | - $ok = ($s === $a); |
|
| 242 | - spip_fclose_unlock($fp2); |
|
| 243 | - spip_fclose_unlock($fp); |
|
| 244 | - $fp = null; |
|
| 245 | - // unlink direct et pas spip_unlink car on avait deja le verrou |
|
| 246 | - // a priori pas besoin car rename ecrase la cible |
|
| 247 | - // @unlink($fichier); |
|
| 248 | - // le rename aussitot, atomique quand on est pas sous windows |
|
| 249 | - // au pire on arrive en second en cas de concourance, et le rename echoue |
|
| 250 | - // --> on a la version de l'autre process qui doit etre identique |
|
| 251 | - @rename("$fichier.$id", $fichier); |
|
| 252 | - // precaution en cas d'echec du rename |
|
| 253 | - if (!_TEST_FILE_EXISTS || @file_exists("$fichier.$id")) { |
|
| 254 | - @unlink("$fichier.$id"); |
|
| 255 | - } |
|
| 256 | - if ($ok) { |
|
| 257 | - $ok = file_exists($fichier); |
|
| 258 | - } |
|
| 259 | - } else // echec mais penser a fermer .. |
|
| 260 | - { |
|
| 261 | - spip_fclose_unlock($fp); |
|
| 262 | - $fp = null; |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - // sinon ou si methode precedente a echoueee |
|
| 266 | - // on se rabat sur la methode ancienne |
|
| 267 | - if (!$ok && !is_null($fp)) { |
|
| 268 | - // ici on est en ajout ou sous windows, cas desespere |
|
| 269 | - if ($truncate) { |
|
| 270 | - @ftruncate($fp, 0); |
|
| 271 | - } |
|
| 272 | - $s = @fwrite($fp, $contenu, $a = strlen($contenu)); |
|
| 273 | - |
|
| 274 | - $ok = ($s == $a); |
|
| 275 | - spip_fclose_unlock($fp); |
|
| 276 | - } |
|
| 277 | - // on tente une dernière fois file_put_contents |
|
| 278 | - if (!$ok) { |
|
| 279 | - $l = file_put_contents($fichier, $contenu, $truncate ? LOCK_EX : LOCK_EX | FILE_APPEND); |
|
| 280 | - $ok = ($l === strlen($contenu)); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - // liberer le verrou et fermer le fichier |
|
| 284 | - @chmod($fichier, _SPIP_CHMOD & 0666); |
|
| 285 | - if ($ok) { |
|
| 286 | - if (str_contains($fichier, '.php')) { |
|
| 287 | - spip_clear_opcode_cache(realpath($fichier)); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - return $ok; |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - if (!$ignorer_echec) { |
|
| 295 | - include_spip('inc/autoriser'); |
|
| 296 | - if (autoriser('chargerftp')) { |
|
| 297 | - raler_fichier($fichier); |
|
| 298 | - } |
|
| 299 | - spip_unlink($fichier); |
|
| 300 | - } |
|
| 301 | - spip_logger()->notice("Ecriture fichier $fichier impossible"); |
|
| 302 | - |
|
| 303 | - return false; |
|
| 218 | + #spip_timer('ecrire_fichier'); |
|
| 219 | + |
|
| 220 | + // verrouiller le fichier destination |
|
| 221 | + if ($fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 222 | + // ecrire les donnees, compressees le cas echeant |
|
| 223 | + // (on ouvre un nouveau pointeur sur le fichier, ce qui a l'avantage |
|
| 224 | + // de le recreer si le locker qui nous precede l'avait supprime...) |
|
| 225 | + if (str_ends_with($fichier, '.gz')) { |
|
| 226 | + $contenu = gzencode($contenu); |
|
| 227 | + } |
|
| 228 | + // si c'est une ecriture avec troncation , on fait plutot une ecriture complete a cote suivie unlink+rename |
|
| 229 | + // pour etre sur d'avoir une operation atomique |
|
| 230 | + // y compris en NFS : http://www.ietf.org/rfc/rfc1094.txt |
|
| 231 | + // sauf sous wintruc ou ca ne marche pas |
|
| 232 | + $ok = false; |
|
| 233 | + if ($truncate && _OS_SERVEUR != 'windows') { |
|
| 234 | + if (!function_exists('creer_uniqid')) { |
|
| 235 | + include_spip('inc/acces'); |
|
| 236 | + } |
|
| 237 | + $id = creer_uniqid(); |
|
| 238 | + // on ouvre un pointeur sur un fichier temporaire en ecriture +raz |
|
| 239 | + if ($fp2 = spip_fopen_lock("$fichier.$id", 'w', LOCK_EX)) { |
|
| 240 | + $s = @fwrite($fp2, (string) $contenu, $a = strlen((string) $contenu)); |
|
| 241 | + $ok = ($s === $a); |
|
| 242 | + spip_fclose_unlock($fp2); |
|
| 243 | + spip_fclose_unlock($fp); |
|
| 244 | + $fp = null; |
|
| 245 | + // unlink direct et pas spip_unlink car on avait deja le verrou |
|
| 246 | + // a priori pas besoin car rename ecrase la cible |
|
| 247 | + // @unlink($fichier); |
|
| 248 | + // le rename aussitot, atomique quand on est pas sous windows |
|
| 249 | + // au pire on arrive en second en cas de concourance, et le rename echoue |
|
| 250 | + // --> on a la version de l'autre process qui doit etre identique |
|
| 251 | + @rename("$fichier.$id", $fichier); |
|
| 252 | + // precaution en cas d'echec du rename |
|
| 253 | + if (!_TEST_FILE_EXISTS || @file_exists("$fichier.$id")) { |
|
| 254 | + @unlink("$fichier.$id"); |
|
| 255 | + } |
|
| 256 | + if ($ok) { |
|
| 257 | + $ok = file_exists($fichier); |
|
| 258 | + } |
|
| 259 | + } else // echec mais penser a fermer .. |
|
| 260 | + { |
|
| 261 | + spip_fclose_unlock($fp); |
|
| 262 | + $fp = null; |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + // sinon ou si methode precedente a echoueee |
|
| 266 | + // on se rabat sur la methode ancienne |
|
| 267 | + if (!$ok && !is_null($fp)) { |
|
| 268 | + // ici on est en ajout ou sous windows, cas desespere |
|
| 269 | + if ($truncate) { |
|
| 270 | + @ftruncate($fp, 0); |
|
| 271 | + } |
|
| 272 | + $s = @fwrite($fp, $contenu, $a = strlen($contenu)); |
|
| 273 | + |
|
| 274 | + $ok = ($s == $a); |
|
| 275 | + spip_fclose_unlock($fp); |
|
| 276 | + } |
|
| 277 | + // on tente une dernière fois file_put_contents |
|
| 278 | + if (!$ok) { |
|
| 279 | + $l = file_put_contents($fichier, $contenu, $truncate ? LOCK_EX : LOCK_EX | FILE_APPEND); |
|
| 280 | + $ok = ($l === strlen($contenu)); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + // liberer le verrou et fermer le fichier |
|
| 284 | + @chmod($fichier, _SPIP_CHMOD & 0666); |
|
| 285 | + if ($ok) { |
|
| 286 | + if (str_contains($fichier, '.php')) { |
|
| 287 | + spip_clear_opcode_cache(realpath($fichier)); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + return $ok; |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + if (!$ignorer_echec) { |
|
| 295 | + include_spip('inc/autoriser'); |
|
| 296 | + if (autoriser('chargerftp')) { |
|
| 297 | + raler_fichier($fichier); |
|
| 298 | + } |
|
| 299 | + spip_unlink($fichier); |
|
| 300 | + } |
|
| 301 | + spip_logger()->notice("Ecriture fichier $fichier impossible"); |
|
| 302 | + |
|
| 303 | + return false; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -320,12 +320,12 @@ discard block |
||
| 320 | 320 | * Écriture avec troncation ? |
| 321 | 321 | */ |
| 322 | 322 | function ecrire_fichier_securise($fichier, $contenu, $ecrire_quand_meme = false, $truncate = true) { |
| 323 | - if (!str_ends_with($fichier, '.php')) { |
|
| 324 | - spip_logger()->info('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 325 | - } |
|
| 326 | - $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 323 | + if (!str_ends_with($fichier, '.php')) { |
|
| 324 | + spip_logger()->info('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 325 | + } |
|
| 326 | + $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 327 | 327 | |
| 328 | - return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
|
| 328 | + return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -336,25 +336,25 @@ discard block |
||
| 336 | 336 | * @return bool |
| 337 | 337 | */ |
| 338 | 338 | function ecrire_fichier_calcule_si_modifie($fichier, $contenu, $force = false, $use_copy = false) { |
| 339 | - $fichier_tmp = $fichier . '.last'; |
|
| 340 | - if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
|
| 341 | - return false; |
|
| 342 | - } |
|
| 343 | - if ( |
|
| 344 | - $force |
|
| 345 | - || !file_exists($fichier) |
|
| 346 | - || md5_file($fichier) !== md5_file($fichier_tmp) |
|
| 347 | - ) { |
|
| 348 | - if ($use_copy) { |
|
| 349 | - @copy($fichier_tmp, $fichier); |
|
| 350 | - } |
|
| 351 | - else { |
|
| 352 | - @rename($fichier_tmp, $fichier); |
|
| 353 | - } |
|
| 354 | - // eviter que PHP ne reserve le vieux timestamp |
|
| 355 | - clearstatcache(true, $fichier); |
|
| 356 | - } |
|
| 357 | - return true; |
|
| 339 | + $fichier_tmp = $fichier . '.last'; |
|
| 340 | + if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + if ( |
|
| 344 | + $force |
|
| 345 | + || !file_exists($fichier) |
|
| 346 | + || md5_file($fichier) !== md5_file($fichier_tmp) |
|
| 347 | + ) { |
|
| 348 | + if ($use_copy) { |
|
| 349 | + @copy($fichier_tmp, $fichier); |
|
| 350 | + } |
|
| 351 | + else { |
|
| 352 | + @rename($fichier_tmp, $fichier); |
|
| 353 | + } |
|
| 354 | + // eviter que PHP ne reserve le vieux timestamp |
|
| 355 | + clearstatcache(true, $fichier); |
|
| 356 | + } |
|
| 357 | + return true; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | |
@@ -375,11 +375,11 @@ discard block |
||
| 375 | 375 | * true si l'opération a réussie, false sinon. |
| 376 | 376 | */ |
| 377 | 377 | function lire_fichier_securise($fichier, &$contenu, $options = []) { |
| 378 | - if ($res = lire_fichier($fichier, $contenu, $options)) { |
|
| 379 | - $contenu = substr((string) $contenu, strlen('<?php die (\'Acces interdit\'); ?>' . "\n")); |
|
| 380 | - } |
|
| 378 | + if ($res = lire_fichier($fichier, $contenu, $options)) { |
|
| 379 | + $contenu = substr((string) $contenu, strlen('<?php die (\'Acces interdit\'); ?>' . "\n")); |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - return $res; |
|
| 382 | + return $res; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -391,25 +391,25 @@ discard block |
||
| 391 | 391 | * @uses minipres() Pour afficher le message |
| 392 | 392 | **/ |
| 393 | 393 | function raler_fichier(string $fichier): never { |
| 394 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 395 | - spip_initialisation_suite(); |
|
| 396 | - } |
|
| 397 | - include_spip('inc/minipres'); |
|
| 398 | - $dir = dirname($fichier); |
|
| 399 | - http_response_code(401); |
|
| 400 | - echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 401 | - . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 402 | - . " <a href='" |
|
| 403 | - . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 404 | - . "'>" |
|
| 405 | - . _T('texte_inc_meta_2') |
|
| 406 | - . '</a> ' |
|
| 407 | - . _T( |
|
| 408 | - 'texte_inc_meta_3', |
|
| 409 | - ['repertoire' => joli_repertoire($dir)] |
|
| 410 | - ) |
|
| 411 | - . "</h4>\n"); |
|
| 412 | - exit; |
|
| 394 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 395 | + spip_initialisation_suite(); |
|
| 396 | + } |
|
| 397 | + include_spip('inc/minipres'); |
|
| 398 | + $dir = dirname($fichier); |
|
| 399 | + http_response_code(401); |
|
| 400 | + echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 401 | + . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 402 | + . " <a href='" |
|
| 403 | + . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 404 | + . "'>" |
|
| 405 | + . _T('texte_inc_meta_2') |
|
| 406 | + . '</a> ' |
|
| 407 | + . _T( |
|
| 408 | + 'texte_inc_meta_3', |
|
| 409 | + ['repertoire' => joli_repertoire($dir)] |
|
| 410 | + ) |
|
| 411 | + . "</h4>\n"); |
|
| 412 | + exit; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | |
@@ -424,14 +424,14 @@ discard block |
||
| 424 | 424 | * - true si récent, false sinon |
| 425 | 425 | */ |
| 426 | 426 | function jeune_fichier($fichier, $n) { |
| 427 | - if (!file_exists($fichier)) { |
|
| 428 | - return false; |
|
| 429 | - } |
|
| 430 | - if (!$c = @filemtime($fichier)) { |
|
| 431 | - return false; |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - return (time() - $n <= $c); |
|
| 427 | + if (!file_exists($fichier)) { |
|
| 428 | + return false; |
|
| 429 | + } |
|
| 430 | + if (!$c = @filemtime($fichier)) { |
|
| 431 | + return false; |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + return (time() - $n <= $c); |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -446,22 +446,22 @@ discard block |
||
| 446 | 446 | * - false si on n'arrive pas poser le verrou ou si la suppression échoue |
| 447 | 447 | */ |
| 448 | 448 | function supprimer_fichier($fichier, $lock = true) { |
| 449 | - if (!@file_exists($fichier)) { |
|
| 450 | - return true; |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - if ($lock) { |
|
| 454 | - // verrouiller le fichier destination |
|
| 455 | - if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 456 | - return false; |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - // liberer le verrou |
|
| 460 | - spip_fclose_unlock($fp); |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - // supprimer |
|
| 464 | - return @unlink($fichier); |
|
| 449 | + if (!@file_exists($fichier)) { |
|
| 450 | + return true; |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + if ($lock) { |
|
| 454 | + // verrouiller le fichier destination |
|
| 455 | + if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 456 | + return false; |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + // liberer le verrou |
|
| 460 | + spip_fclose_unlock($fp); |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + // supprimer |
|
| 464 | + return @unlink($fichier); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -471,12 +471,12 @@ discard block |
||
| 471 | 471 | * Chemin du fichier |
| 472 | 472 | */ |
| 473 | 473 | function spip_unlink($f) { |
| 474 | - if (!is_dir($f)) { |
|
| 475 | - supprimer_fichier($f, false); |
|
| 476 | - } else { |
|
| 477 | - @unlink("$f/.ok"); |
|
| 478 | - @rmdir($f); |
|
| 479 | - } |
|
| 474 | + if (!is_dir($f)) { |
|
| 475 | + supprimer_fichier($f, false); |
|
| 476 | + } else { |
|
| 477 | + @unlink("$f/.ok"); |
|
| 478 | + @rmdir($f); |
|
| 479 | + } |
|
| 480 | 480 | } |
| 481 | 481 | |
| 482 | 482 | /** |
@@ -490,26 +490,26 @@ discard block |
||
| 490 | 490 | * The absolute path of the PHP file to invalidate. |
| 491 | 491 | */ |
| 492 | 492 | function spip_clear_opcode_cache($filepath) { |
| 493 | - clearstatcache(true, $filepath); |
|
| 494 | - |
|
| 495 | - // Zend OPcache |
|
| 496 | - if (function_exists('opcache_invalidate')) { |
|
| 497 | - $invalidate = @opcache_invalidate($filepath, true); |
|
| 498 | - // si l'invalidation a echoue lever un flag |
|
| 499 | - if (!$invalidate && !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 500 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 501 | - } |
|
| 502 | - } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 503 | - // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 504 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 505 | - } |
|
| 506 | - // APC. |
|
| 507 | - if (function_exists('apc_delete_file')) { |
|
| 508 | - // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 509 | - // not compiled yet. |
|
| 510 | - // @see http://php.net/apc-delete-file |
|
| 511 | - @apc_delete_file($filepath); |
|
| 512 | - } |
|
| 493 | + clearstatcache(true, $filepath); |
|
| 494 | + |
|
| 495 | + // Zend OPcache |
|
| 496 | + if (function_exists('opcache_invalidate')) { |
|
| 497 | + $invalidate = @opcache_invalidate($filepath, true); |
|
| 498 | + // si l'invalidation a echoue lever un flag |
|
| 499 | + if (!$invalidate && !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 500 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 501 | + } |
|
| 502 | + } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 503 | + // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 504 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 505 | + } |
|
| 506 | + // APC. |
|
| 507 | + if (function_exists('apc_delete_file')) { |
|
| 508 | + // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 509 | + // not compiled yet. |
|
| 510 | + // @see http://php.net/apc-delete-file |
|
| 511 | + @apc_delete_file($filepath); |
|
| 512 | + } |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | /** |
@@ -532,25 +532,25 @@ discard block |
||
| 532 | 532 | * |
| 533 | 533 | */ |
| 534 | 534 | function spip_attend_invalidation_opcode_cache($timestamp = null) { |
| 535 | - if ( |
|
| 536 | - function_exists('opcache_get_configuration') |
|
| 537 | - && @ini_get('opcache.enable') |
|
| 538 | - && @ini_get('opcache.validate_timestamps') |
|
| 539 | - && (($duree = (int) @ini_get('opcache.revalidate_freq')) || ($duree = 2)) |
|
| 540 | - && defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 541 | - ) { |
|
| 542 | - $wait = $duree + 1; |
|
| 543 | - if ($timestamp) { |
|
| 544 | - $wait -= (time() - $timestamp); |
|
| 545 | - if ($wait < 0) { |
|
| 546 | - $wait = 0; |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - spip_logger()->notice('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's'); |
|
| 550 | - if ($wait) { |
|
| 551 | - sleep($duree + 1); |
|
| 552 | - } |
|
| 553 | - } |
|
| 535 | + if ( |
|
| 536 | + function_exists('opcache_get_configuration') |
|
| 537 | + && @ini_get('opcache.enable') |
|
| 538 | + && @ini_get('opcache.validate_timestamps') |
|
| 539 | + && (($duree = (int) @ini_get('opcache.revalidate_freq')) || ($duree = 2)) |
|
| 540 | + && defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 541 | + ) { |
|
| 542 | + $wait = $duree + 1; |
|
| 543 | + if ($timestamp) { |
|
| 544 | + $wait -= (time() - $timestamp); |
|
| 545 | + if ($wait < 0) { |
|
| 546 | + $wait = 0; |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + spip_logger()->notice('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's'); |
|
| 550 | + if ($wait) { |
|
| 551 | + sleep($duree + 1); |
|
| 552 | + } |
|
| 553 | + } |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | |
@@ -563,26 +563,26 @@ discard block |
||
| 563 | 563 | * @return bool Suppression reussie. |
| 564 | 564 | */ |
| 565 | 565 | function supprimer_repertoire($dir) { |
| 566 | - if (!file_exists($dir)) { |
|
| 567 | - return true; |
|
| 568 | - } |
|
| 569 | - if (!is_dir($dir) || is_link($dir)) { |
|
| 570 | - return @unlink($dir); |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - foreach (scandir($dir) as $item) { |
|
| 574 | - if ($item == '.' || $item == '..') { |
|
| 575 | - continue; |
|
| 576 | - } |
|
| 577 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 578 | - @chmod($dir . '/' . $item, 0777); |
|
| 579 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 580 | - return false; |
|
| 581 | - } |
|
| 582 | - }; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - return @rmdir($dir); |
|
| 566 | + if (!file_exists($dir)) { |
|
| 567 | + return true; |
|
| 568 | + } |
|
| 569 | + if (!is_dir($dir) || is_link($dir)) { |
|
| 570 | + return @unlink($dir); |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + foreach (scandir($dir) as $item) { |
|
| 574 | + if ($item == '.' || $item == '..') { |
|
| 575 | + continue; |
|
| 576 | + } |
|
| 577 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 578 | + @chmod($dir . '/' . $item, 0777); |
|
| 579 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 580 | + return false; |
|
| 581 | + } |
|
| 582 | + }; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + return @rmdir($dir); |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | |
@@ -611,58 +611,58 @@ discard block |
||
| 611 | 611 | * Chemin du répertoire créé. |
| 612 | 612 | **/ |
| 613 | 613 | function sous_repertoire($base, $subdir = '', $nobase = false, $tantpis = false): string { |
| 614 | - static $dirs = []; |
|
| 615 | - |
|
| 616 | - $base = str_replace('//', '/', $base); |
|
| 617 | - |
|
| 618 | - # suppr le dernier caractere si c'est un / |
|
| 619 | - $base = rtrim($base, '/'); |
|
| 620 | - |
|
| 621 | - if (!strlen($subdir)) { |
|
| 622 | - $n = strrpos($base, '/'); |
|
| 623 | - if ($n === false) { |
|
| 624 | - return $nobase ? '' : ($base . '/'); |
|
| 625 | - } |
|
| 626 | - $subdir = substr($base, $n + 1); |
|
| 627 | - $base = substr($base, 0, $n + 1); |
|
| 628 | - } else { |
|
| 629 | - $base .= '/'; |
|
| 630 | - $subdir = str_replace('/', '', $subdir); |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - $baseaff = $nobase ? '' : $base; |
|
| 634 | - if (isset($dirs[$base . $subdir])) { |
|
| 635 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 639 | - |
|
| 640 | - if (file_exists("$path/.ok")) { |
|
| 641 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - @mkdir($path, _SPIP_CHMOD); |
|
| 645 | - @chmod($path, _SPIP_CHMOD); |
|
| 646 | - |
|
| 647 | - if (is_dir($path) && is_writable($path)) { |
|
| 648 | - @touch("$path/.ok"); |
|
| 649 | - spip_logger()->info("creation $base$subdir/"); |
|
| 650 | - |
|
| 651 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 655 | - // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 656 | - spip_logger()->info("echec creation $base{$subdir}"); |
|
| 657 | - if ($tantpis) { |
|
| 658 | - return ''; |
|
| 659 | - } |
|
| 660 | - // FIXME: throw an Exception… |
|
| 661 | - if (!_DIR_RESTREINT) { |
|
| 662 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 663 | - } |
|
| 664 | - $base .= $subdir; |
|
| 665 | - raler_fichier($base . '/.ok'); |
|
| 614 | + static $dirs = []; |
|
| 615 | + |
|
| 616 | + $base = str_replace('//', '/', $base); |
|
| 617 | + |
|
| 618 | + # suppr le dernier caractere si c'est un / |
|
| 619 | + $base = rtrim($base, '/'); |
|
| 620 | + |
|
| 621 | + if (!strlen($subdir)) { |
|
| 622 | + $n = strrpos($base, '/'); |
|
| 623 | + if ($n === false) { |
|
| 624 | + return $nobase ? '' : ($base . '/'); |
|
| 625 | + } |
|
| 626 | + $subdir = substr($base, $n + 1); |
|
| 627 | + $base = substr($base, 0, $n + 1); |
|
| 628 | + } else { |
|
| 629 | + $base .= '/'; |
|
| 630 | + $subdir = str_replace('/', '', $subdir); |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + $baseaff = $nobase ? '' : $base; |
|
| 634 | + if (isset($dirs[$base . $subdir])) { |
|
| 635 | + return $baseaff . $dirs[$base . $subdir]; |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 639 | + |
|
| 640 | + if (file_exists("$path/.ok")) { |
|
| 641 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + @mkdir($path, _SPIP_CHMOD); |
|
| 645 | + @chmod($path, _SPIP_CHMOD); |
|
| 646 | + |
|
| 647 | + if (is_dir($path) && is_writable($path)) { |
|
| 648 | + @touch("$path/.ok"); |
|
| 649 | + spip_logger()->info("creation $base$subdir/"); |
|
| 650 | + |
|
| 651 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 655 | + // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 656 | + spip_logger()->info("echec creation $base{$subdir}"); |
|
| 657 | + if ($tantpis) { |
|
| 658 | + return ''; |
|
| 659 | + } |
|
| 660 | + // FIXME: throw an Exception… |
|
| 661 | + if (!_DIR_RESTREINT) { |
|
| 662 | + $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 663 | + } |
|
| 664 | + $base .= $subdir; |
|
| 665 | + raler_fichier($base . '/.ok'); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | |
@@ -695,55 +695,55 @@ discard block |
||
| 695 | 695 | * Chemins des fichiers trouvés. |
| 696 | 696 | **/ |
| 697 | 697 | function preg_files($dir, $pattern = -1 /* AUTO */, $maxfiles = 10000, $recurs = []) { |
| 698 | - $nbfiles = 0; |
|
| 699 | - if ($pattern == -1) { |
|
| 700 | - $pattern = ''; |
|
| 701 | - } |
|
| 702 | - $fichiers = []; |
|
| 703 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 704 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 705 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 706 | - if ($dir == '') { |
|
| 707 | - $dir = '.'; |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 711 | - while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 712 | - if ( |
|
| 713 | - $f[0] != '.' |
|
| 714 | - && $f != 'remove.txt' |
|
| 715 | - && is_readable($f = "$dir/$f") |
|
| 716 | - ) { |
|
| 717 | - if (is_file($f)) { |
|
| 718 | - if (!$pattern || preg_match(";$pattern;iS", $f)) { |
|
| 719 | - $fichiers[] = $f; |
|
| 720 | - $nbfiles++; |
|
| 721 | - } |
|
| 722 | - } else { |
|
| 723 | - if (is_dir($f) && is_array($recurs)) { |
|
| 724 | - $rp = @realpath($f); |
|
| 725 | - if (!is_string($rp) || !strlen($rp)) { |
|
| 726 | - $rp = $f; |
|
| 727 | - } # realpath n'est peut etre pas autorise |
|
| 728 | - if (!isset($recurs[$rp])) { |
|
| 729 | - $recurs[$rp] = true; |
|
| 730 | - $beginning = $fichiers; |
|
| 731 | - $end = preg_files( |
|
| 732 | - "$f/", |
|
| 733 | - $pattern, |
|
| 734 | - $maxfiles - $nbfiles, |
|
| 735 | - $recurs |
|
| 736 | - ); |
|
| 737 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 738 | - $nbfiles = count($fichiers); |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - } |
|
| 742 | - } |
|
| 743 | - } |
|
| 744 | - closedir($d); |
|
| 745 | - } |
|
| 746 | - sort($fichiers); |
|
| 747 | - |
|
| 748 | - return $fichiers; |
|
| 698 | + $nbfiles = 0; |
|
| 699 | + if ($pattern == -1) { |
|
| 700 | + $pattern = ''; |
|
| 701 | + } |
|
| 702 | + $fichiers = []; |
|
| 703 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 704 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 705 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 706 | + if ($dir == '') { |
|
| 707 | + $dir = '.'; |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 711 | + while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 712 | + if ( |
|
| 713 | + $f[0] != '.' |
|
| 714 | + && $f != 'remove.txt' |
|
| 715 | + && is_readable($f = "$dir/$f") |
|
| 716 | + ) { |
|
| 717 | + if (is_file($f)) { |
|
| 718 | + if (!$pattern || preg_match(";$pattern;iS", $f)) { |
|
| 719 | + $fichiers[] = $f; |
|
| 720 | + $nbfiles++; |
|
| 721 | + } |
|
| 722 | + } else { |
|
| 723 | + if (is_dir($f) && is_array($recurs)) { |
|
| 724 | + $rp = @realpath($f); |
|
| 725 | + if (!is_string($rp) || !strlen($rp)) { |
|
| 726 | + $rp = $f; |
|
| 727 | + } # realpath n'est peut etre pas autorise |
|
| 728 | + if (!isset($recurs[$rp])) { |
|
| 729 | + $recurs[$rp] = true; |
|
| 730 | + $beginning = $fichiers; |
|
| 731 | + $end = preg_files( |
|
| 732 | + "$f/", |
|
| 733 | + $pattern, |
|
| 734 | + $maxfiles - $nbfiles, |
|
| 735 | + $recurs |
|
| 736 | + ); |
|
| 737 | + $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 738 | + $nbfiles = count($fichiers); |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | + closedir($d); |
|
| 745 | + } |
|
| 746 | + sort($fichiers); |
|
| 747 | + |
|
| 748 | + return $fichiers; |
|
| 749 | 749 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $contenu = @gzfile($fichier); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return is_array($contenu) ? implode('', $contenu) : (string)$contenu; |
|
| 124 | + return is_array($contenu) ? implode('', $contenu) : (string) $contenu; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -321,9 +321,9 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | function ecrire_fichier_securise($fichier, $contenu, $ecrire_quand_meme = false, $truncate = true) { |
| 323 | 323 | if (!str_ends_with($fichier, '.php')) { |
| 324 | - spip_logger()->info('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 324 | + spip_logger()->info('Erreur de programmation: '.$fichier.' doit finir par .php'); |
|
| 325 | 325 | } |
| 326 | - $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 326 | + $contenu = '<'."?php die ('Acces interdit'); ?".">\n".$contenu; |
|
| 327 | 327 | |
| 328 | 328 | return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
| 329 | 329 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @return bool |
| 337 | 337 | */ |
| 338 | 338 | function ecrire_fichier_calcule_si_modifie($fichier, $contenu, $force = false, $use_copy = false) { |
| 339 | - $fichier_tmp = $fichier . '.last'; |
|
| 339 | + $fichier_tmp = $fichier.'.last'; |
|
| 340 | 340 | if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
| 341 | 341 | return false; |
| 342 | 342 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | function lire_fichier_securise($fichier, &$contenu, $options = []) { |
| 378 | 378 | if ($res = lire_fichier($fichier, $contenu, $options)) { |
| 379 | - $contenu = substr((string) $contenu, strlen('<?php die (\'Acces interdit\'); ?>' . "\n")); |
|
| 379 | + $contenu = substr((string) $contenu, strlen('<?php die (\'Acces interdit\'); ?>'."\n")); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | return $res; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | $wait = 0; |
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | - spip_logger()->notice('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's'); |
|
| 549 | + spip_logger()->notice('Probleme de configuration opcache.revalidate_freq '.$duree.'s : on attend '.$wait.'s'); |
|
| 550 | 550 | if ($wait) { |
| 551 | 551 | sleep($duree + 1); |
| 552 | 552 | } |
@@ -574,9 +574,9 @@ discard block |
||
| 574 | 574 | if ($item == '.' || $item == '..') { |
| 575 | 575 | continue; |
| 576 | 576 | } |
| 577 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 578 | - @chmod($dir . '/' . $item, 0777); |
|
| 579 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 577 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 578 | + @chmod($dir.'/'.$item, 0777); |
|
| 579 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 580 | 580 | return false; |
| 581 | 581 | } |
| 582 | 582 | }; |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | if (!strlen($subdir)) { |
| 622 | 622 | $n = strrpos($base, '/'); |
| 623 | 623 | if ($n === false) { |
| 624 | - return $nobase ? '' : ($base . '/'); |
|
| 624 | + return $nobase ? '' : ($base.'/'); |
|
| 625 | 625 | } |
| 626 | 626 | $subdir = substr($base, $n + 1); |
| 627 | 627 | $base = substr($base, 0, $n + 1); |
@@ -631,14 +631,14 @@ discard block |
||
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | $baseaff = $nobase ? '' : $base; |
| 634 | - if (isset($dirs[$base . $subdir])) { |
|
| 635 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 634 | + if (isset($dirs[$base.$subdir])) { |
|
| 635 | + return $baseaff.$dirs[$base.$subdir]; |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 638 | + $path = $base.$subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 639 | 639 | |
| 640 | 640 | if (file_exists("$path/.ok")) { |
| 641 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 641 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | @mkdir($path, _SPIP_CHMOD); |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | @touch("$path/.ok"); |
| 649 | 649 | spip_logger()->info("creation $base$subdir/"); |
| 650 | 650 | |
| 651 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 651 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
@@ -659,10 +659,10 @@ discard block |
||
| 659 | 659 | } |
| 660 | 660 | // FIXME: throw an Exception… |
| 661 | 661 | if (!_DIR_RESTREINT) { |
| 662 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 662 | + $base = preg_replace(',^'._DIR_RACINE.',', '', $base); |
|
| 663 | 663 | } |
| 664 | 664 | $base .= $subdir; |
| 665 | - raler_fichier($base . '/.ok'); |
|
| 665 | + raler_fichier($base.'/.ok'); |
|
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | $maxfiles - $nbfiles, |
| 735 | 735 | $recurs |
| 736 | 736 | ); |
| 737 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 737 | + $fichiers = array_merge((array) $beginning, (array) $end); |
|
| 738 | 738 | $nbfiles = count($fichiers); |
| 739 | 739 | } |
| 740 | 740 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * - ou tableau d'information sur le squelette. |
| 37 | 37 | */ |
| 38 | 38 | function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) { |
| 39 | - // compat avec anciens appels |
|
| 40 | - $objet = objet_type($objet); |
|
| 39 | + // compat avec anciens appels |
|
| 40 | + $objet = objet_type($objet); |
|
| 41 | 41 | |
| 42 | - return recuperer_fond( |
|
| 43 | - 'prive/objets/editer/logo', |
|
| 44 | - ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | - ); |
|
| 42 | + return recuperer_fond( |
|
| 43 | + 'prive/objets/editer/logo', |
|
| 44 | + ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | + ); |
|
| 46 | 46 | } |
@@ -18,206 +18,206 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $GLOBALS['codes_langues'] = [ |
| 25 | - 'aa' => 'Afar', |
|
| 26 | - 'ab' => 'Abkhazian', |
|
| 27 | - 'af' => 'Afrikaans', |
|
| 28 | - 'am' => 'Amharic', |
|
| 29 | - 'an' => 'Aragonés', |
|
| 30 | - 'ar' => 'عربي', |
|
| 31 | - 'as' => 'Assamese', |
|
| 32 | - 'ast' => 'asturianu', |
|
| 33 | - 'ay' => 'Aymara', |
|
| 34 | - 'az' => 'Azərbaycan dili', |
|
| 35 | - 'ba' => 'Bashkir', |
|
| 36 | - 'be' => 'Беларуская', |
|
| 37 | - 'ber_tam' => 'Tamazigh', |
|
| 38 | - 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | - 'bg' => 'български', |
|
| 40 | - 'bh' => 'Bihari', |
|
| 41 | - 'bi' => 'Bislama', |
|
| 42 | - 'bm' => 'Bambara', |
|
| 43 | - 'bn' => 'Bengali; Bangla', |
|
| 44 | - 'bo' => 'Tibetan', |
|
| 45 | - 'br' => 'brezhoneg', |
|
| 46 | - 'bs' => 'bosanski', |
|
| 47 | - 'ca' => 'català', |
|
| 48 | - 'co' => 'corsu', |
|
| 49 | - 'cpf' => 'Kréol réyoné', |
|
| 50 | - 'cpf_dom' => 'Kreyòl', |
|
| 51 | - 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | - 'cs' => 'čeština', |
|
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | - 'da' => 'dansk', |
|
| 55 | - 'de' => 'Deutsch', |
|
| 56 | - 'dz' => 'Bhutani', |
|
| 57 | - 'el' => 'ελληνικά', |
|
| 58 | - 'en' => 'English', |
|
| 59 | - 'en_hx' => 'H4ck3R', |
|
| 60 | - 'en_sm' => 'Smurf', |
|
| 61 | - 'eo' => 'Esperanto', |
|
| 62 | - 'es' => 'Español', |
|
| 63 | - 'es_co' => 'Colombiano', |
|
| 64 | - 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | - 'et' => 'eesti', |
|
| 66 | - 'eu' => 'euskara', |
|
| 67 | - 'fa' => 'فارسى', |
|
| 68 | - 'ff' => 'Fulah', // peul |
|
| 69 | - 'fi' => 'suomi', |
|
| 70 | - 'fj' => 'Fiji', |
|
| 71 | - 'fo' => 'føroyskt', |
|
| 72 | - 'fon' => 'fongbè', |
|
| 73 | - 'fr' => 'français', |
|
| 74 | - 'fr_fem' => 'français féminin', |
|
| 75 | - 'fr_sc' => 'schtroumpf', |
|
| 76 | - 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | - 'fr_lsf' => 'langue des signes française', |
|
| 78 | - 'fr_spl' => 'français simplifié', |
|
| 79 | - 'fr_tu' => 'français copain', |
|
| 80 | - 'fy' => 'Frisian', |
|
| 81 | - 'ga' => 'Irish', |
|
| 82 | - 'gd' => 'Scots Gaelic', |
|
| 83 | - 'gl' => 'galego', |
|
| 84 | - 'gn' => 'Guarani', |
|
| 85 | - 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | - 'gu' => 'Gujarati', |
|
| 87 | - 'ha' => 'Hausa', |
|
| 88 | - 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | - 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | - 'haz' => 'هزاره گی', |
|
| 91 | - 'he' => 'עברית', |
|
| 92 | - 'hi' => 'हिंदी', |
|
| 93 | - 'hr' => 'hrvatski', |
|
| 94 | - 'hu' => 'magyar', |
|
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 96 | - 'ia' => 'Interlingua', |
|
| 97 | - 'id' => 'Indonesia', |
|
| 98 | - 'ie' => 'Interlingue', |
|
| 99 | - 'ik' => 'Inupiak', |
|
| 100 | - 'is' => 'íslenska', |
|
| 101 | - 'it' => 'italiano', |
|
| 102 | - 'it_fem' => 'italiana', |
|
| 103 | - 'iu' => 'Inuktitut', |
|
| 104 | - 'ja' => '日本語', |
|
| 105 | - 'jv' => 'Javanese', |
|
| 106 | - 'ka' => 'ქართული', |
|
| 107 | - 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | - 'kl' => 'kalaallisut', |
|
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | - 'kn' => 'Kannada', |
|
| 111 | - 'ko' => '한국어', |
|
| 112 | - 'kok' => 'कोंकणी', |
|
| 113 | - 'ks' => 'Kashmiri', |
|
| 114 | - 'ku' => 'کوردی', |
|
| 115 | - 'ky' => 'Kirghiz', |
|
| 116 | - 'la' => 'lingua latina', |
|
| 117 | - 'lb' => 'Lëtzebuergesch', |
|
| 118 | - 'ln' => 'Lingala', |
|
| 119 | - 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | - 'lt' => 'lietuvių', |
|
| 121 | - 'lu' => 'luba-katanga', |
|
| 122 | - 'lv' => 'latviešu', |
|
| 123 | - 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | - 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | - 'mg' => 'Malagasy', |
|
| 126 | - 'mi' => 'Maori', |
|
| 127 | - 'mk' => 'македонски јазик', |
|
| 128 | - 'ml' => 'Malayalam', |
|
| 129 | - 'mn' => 'Монгол хэл', |
|
| 130 | - 'mo' => 'Moldavian', |
|
| 131 | - 'mos' => 'Moré', |
|
| 132 | - 'mr' => 'मराठी', |
|
| 133 | - 'ms' => 'Bahasa Malaysia', |
|
| 134 | - 'mt' => 'Maltese', |
|
| 135 | - 'my' => 'Burmese', |
|
| 136 | - 'na' => 'Nauru', |
|
| 137 | - 'nap' => 'napulitano', |
|
| 138 | - 'ne' => 'Nepali', |
|
| 139 | - 'nqo' => "N'ko", // www.manden.org |
|
| 140 | - 'nl' => 'Nederlands', |
|
| 141 | - 'no' => 'norsk', |
|
| 142 | - 'nb' => 'norsk bokmål', |
|
| 143 | - 'nn' => 'norsk nynorsk', |
|
| 144 | - 'oc' => 'òc', |
|
| 145 | - 'oc_lnc' => 'òc lengadocian', |
|
| 146 | - 'oc_ni' => 'òc niçard', |
|
| 147 | - 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | - 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | - 'oc_prv' => 'òc provençau', |
|
| 150 | - 'oc_gsc' => 'òc gascon', |
|
| 151 | - 'oc_lms' => 'òc lemosin', |
|
| 152 | - 'oc_auv' => 'òc auvernhat', |
|
| 153 | - 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | - 'om' => '(Afan) Oromo', |
|
| 155 | - 'or' => 'Oriya', |
|
| 156 | - 'pa' => 'Punjabi', |
|
| 157 | - 'pbb' => 'Nasa Yuwe', |
|
| 158 | - 'pl' => 'polski', |
|
| 159 | - 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | - 'ps' => 'پښتو', |
|
| 161 | - 'pt' => 'Português', |
|
| 162 | - 'pt_br' => 'Português do Brasil', |
|
| 163 | - 'qu' => 'Quechua', |
|
| 164 | - 'rm' => 'Rhaeto-Romance', |
|
| 165 | - 'rn' => 'Kirundi', |
|
| 166 | - 'ro' => 'română', |
|
| 167 | - 'roa' => "ch'ti", |
|
| 168 | - 'ru' => 'русский', |
|
| 169 | - 'rw' => 'Kinyarwanda', |
|
| 170 | - 'sa' => 'संस्कृत', |
|
| 171 | - 'sc' => 'sardu', |
|
| 172 | - 'scn' => 'sicilianu', |
|
| 173 | - 'sd' => 'Sindhi', |
|
| 174 | - 'sg' => 'Sangho', |
|
| 175 | - 'sh' => 'srpskohrvastski', |
|
| 176 | - 'sh_latn' => 'srpskohrvastski', |
|
| 177 | - 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | - 'si' => 'Sinhalese', |
|
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | - 'sm' => 'Samoan', |
|
| 182 | - 'sn' => 'Shona', |
|
| 183 | - 'so' => 'Somali', |
|
| 184 | - 'sq' => 'shqip', |
|
| 185 | - 'sr' => 'српски', |
|
| 186 | - 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | - 'sro' => 'sardu campidanésu', |
|
| 188 | - 'ss' => 'Siswati', |
|
| 189 | - 'st' => 'Sesotho', |
|
| 190 | - 'su' => 'Sundanese', |
|
| 191 | - 'sv' => 'svenska', |
|
| 192 | - 'sw' => 'Kiswahili', |
|
| 193 | - 'ta' => 'தமிழ்', // Tamil |
|
| 194 | - 'te' => 'Telugu', |
|
| 195 | - 'tg' => 'Tajik', |
|
| 196 | - 'th' => 'ไทย', |
|
| 197 | - 'ti' => 'Tigrinya', |
|
| 198 | - 'tk' => 'Turkmen', |
|
| 199 | - 'tl' => 'Tagalog', |
|
| 200 | - 'tn' => 'Setswana', |
|
| 201 | - 'to' => 'Tonga', |
|
| 202 | - 'tr' => 'Türkçe', |
|
| 203 | - 'ts' => 'Tsonga', |
|
| 204 | - 'tt' => 'Татар', |
|
| 205 | - 'tw' => 'Twi', |
|
| 206 | - 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | - 'ug' => 'Uighur', |
|
| 208 | - 'uk' => 'українська', |
|
| 209 | - 'ur' => 'ٱردو', |
|
| 210 | - 'uz' => "O'zbekcha", |
|
| 211 | - 'vi' => 'Tiếng Việt', |
|
| 212 | - 'vo' => 'Volapuk', |
|
| 213 | - 'wa' => 'walon', |
|
| 214 | - 'wo' => 'Wolof', |
|
| 215 | - 'xh' => 'Xhosa', |
|
| 216 | - 'yi' => 'Yiddish', |
|
| 217 | - 'yo' => 'Yoruba', |
|
| 218 | - 'za' => 'Zhuang', |
|
| 219 | - 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | - 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | - 'zu' => 'Zulu' |
|
| 25 | + 'aa' => 'Afar', |
|
| 26 | + 'ab' => 'Abkhazian', |
|
| 27 | + 'af' => 'Afrikaans', |
|
| 28 | + 'am' => 'Amharic', |
|
| 29 | + 'an' => 'Aragonés', |
|
| 30 | + 'ar' => 'عربي', |
|
| 31 | + 'as' => 'Assamese', |
|
| 32 | + 'ast' => 'asturianu', |
|
| 33 | + 'ay' => 'Aymara', |
|
| 34 | + 'az' => 'Azərbaycan dili', |
|
| 35 | + 'ba' => 'Bashkir', |
|
| 36 | + 'be' => 'Беларуская', |
|
| 37 | + 'ber_tam' => 'Tamazigh', |
|
| 38 | + 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | + 'bg' => 'български', |
|
| 40 | + 'bh' => 'Bihari', |
|
| 41 | + 'bi' => 'Bislama', |
|
| 42 | + 'bm' => 'Bambara', |
|
| 43 | + 'bn' => 'Bengali; Bangla', |
|
| 44 | + 'bo' => 'Tibetan', |
|
| 45 | + 'br' => 'brezhoneg', |
|
| 46 | + 'bs' => 'bosanski', |
|
| 47 | + 'ca' => 'català', |
|
| 48 | + 'co' => 'corsu', |
|
| 49 | + 'cpf' => 'Kréol réyoné', |
|
| 50 | + 'cpf_dom' => 'Kreyòl', |
|
| 51 | + 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | + 'cs' => 'čeština', |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | + 'da' => 'dansk', |
|
| 55 | + 'de' => 'Deutsch', |
|
| 56 | + 'dz' => 'Bhutani', |
|
| 57 | + 'el' => 'ελληνικά', |
|
| 58 | + 'en' => 'English', |
|
| 59 | + 'en_hx' => 'H4ck3R', |
|
| 60 | + 'en_sm' => 'Smurf', |
|
| 61 | + 'eo' => 'Esperanto', |
|
| 62 | + 'es' => 'Español', |
|
| 63 | + 'es_co' => 'Colombiano', |
|
| 64 | + 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | + 'et' => 'eesti', |
|
| 66 | + 'eu' => 'euskara', |
|
| 67 | + 'fa' => 'فارسى', |
|
| 68 | + 'ff' => 'Fulah', // peul |
|
| 69 | + 'fi' => 'suomi', |
|
| 70 | + 'fj' => 'Fiji', |
|
| 71 | + 'fo' => 'føroyskt', |
|
| 72 | + 'fon' => 'fongbè', |
|
| 73 | + 'fr' => 'français', |
|
| 74 | + 'fr_fem' => 'français féminin', |
|
| 75 | + 'fr_sc' => 'schtroumpf', |
|
| 76 | + 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | + 'fr_lsf' => 'langue des signes française', |
|
| 78 | + 'fr_spl' => 'français simplifié', |
|
| 79 | + 'fr_tu' => 'français copain', |
|
| 80 | + 'fy' => 'Frisian', |
|
| 81 | + 'ga' => 'Irish', |
|
| 82 | + 'gd' => 'Scots Gaelic', |
|
| 83 | + 'gl' => 'galego', |
|
| 84 | + 'gn' => 'Guarani', |
|
| 85 | + 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | + 'gu' => 'Gujarati', |
|
| 87 | + 'ha' => 'Hausa', |
|
| 88 | + 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | + 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | + 'haz' => 'هزاره گی', |
|
| 91 | + 'he' => 'עברית', |
|
| 92 | + 'hi' => 'हिंदी', |
|
| 93 | + 'hr' => 'hrvatski', |
|
| 94 | + 'hu' => 'magyar', |
|
| 95 | + 'hy' => 'Հայերեն',// Arménien |
|
| 96 | + 'ia' => 'Interlingua', |
|
| 97 | + 'id' => 'Indonesia', |
|
| 98 | + 'ie' => 'Interlingue', |
|
| 99 | + 'ik' => 'Inupiak', |
|
| 100 | + 'is' => 'íslenska', |
|
| 101 | + 'it' => 'italiano', |
|
| 102 | + 'it_fem' => 'italiana', |
|
| 103 | + 'iu' => 'Inuktitut', |
|
| 104 | + 'ja' => '日本語', |
|
| 105 | + 'jv' => 'Javanese', |
|
| 106 | + 'ka' => 'ქართული', |
|
| 107 | + 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | + 'kl' => 'kalaallisut', |
|
| 109 | + 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | + 'kn' => 'Kannada', |
|
| 111 | + 'ko' => '한국어', |
|
| 112 | + 'kok' => 'कोंकणी', |
|
| 113 | + 'ks' => 'Kashmiri', |
|
| 114 | + 'ku' => 'کوردی', |
|
| 115 | + 'ky' => 'Kirghiz', |
|
| 116 | + 'la' => 'lingua latina', |
|
| 117 | + 'lb' => 'Lëtzebuergesch', |
|
| 118 | + 'ln' => 'Lingala', |
|
| 119 | + 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | + 'lt' => 'lietuvių', |
|
| 121 | + 'lu' => 'luba-katanga', |
|
| 122 | + 'lv' => 'latviešu', |
|
| 123 | + 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | + 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | + 'mg' => 'Malagasy', |
|
| 126 | + 'mi' => 'Maori', |
|
| 127 | + 'mk' => 'македонски јазик', |
|
| 128 | + 'ml' => 'Malayalam', |
|
| 129 | + 'mn' => 'Монгол хэл', |
|
| 130 | + 'mo' => 'Moldavian', |
|
| 131 | + 'mos' => 'Moré', |
|
| 132 | + 'mr' => 'मराठी', |
|
| 133 | + 'ms' => 'Bahasa Malaysia', |
|
| 134 | + 'mt' => 'Maltese', |
|
| 135 | + 'my' => 'Burmese', |
|
| 136 | + 'na' => 'Nauru', |
|
| 137 | + 'nap' => 'napulitano', |
|
| 138 | + 'ne' => 'Nepali', |
|
| 139 | + 'nqo' => "N'ko", // www.manden.org |
|
| 140 | + 'nl' => 'Nederlands', |
|
| 141 | + 'no' => 'norsk', |
|
| 142 | + 'nb' => 'norsk bokmål', |
|
| 143 | + 'nn' => 'norsk nynorsk', |
|
| 144 | + 'oc' => 'òc', |
|
| 145 | + 'oc_lnc' => 'òc lengadocian', |
|
| 146 | + 'oc_ni' => 'òc niçard', |
|
| 147 | + 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | + 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | + 'oc_prv' => 'òc provençau', |
|
| 150 | + 'oc_gsc' => 'òc gascon', |
|
| 151 | + 'oc_lms' => 'òc lemosin', |
|
| 152 | + 'oc_auv' => 'òc auvernhat', |
|
| 153 | + 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | + 'om' => '(Afan) Oromo', |
|
| 155 | + 'or' => 'Oriya', |
|
| 156 | + 'pa' => 'Punjabi', |
|
| 157 | + 'pbb' => 'Nasa Yuwe', |
|
| 158 | + 'pl' => 'polski', |
|
| 159 | + 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | + 'ps' => 'پښتو', |
|
| 161 | + 'pt' => 'Português', |
|
| 162 | + 'pt_br' => 'Português do Brasil', |
|
| 163 | + 'qu' => 'Quechua', |
|
| 164 | + 'rm' => 'Rhaeto-Romance', |
|
| 165 | + 'rn' => 'Kirundi', |
|
| 166 | + 'ro' => 'română', |
|
| 167 | + 'roa' => "ch'ti", |
|
| 168 | + 'ru' => 'русский', |
|
| 169 | + 'rw' => 'Kinyarwanda', |
|
| 170 | + 'sa' => 'संस्कृत', |
|
| 171 | + 'sc' => 'sardu', |
|
| 172 | + 'scn' => 'sicilianu', |
|
| 173 | + 'sd' => 'Sindhi', |
|
| 174 | + 'sg' => 'Sangho', |
|
| 175 | + 'sh' => 'srpskohrvastski', |
|
| 176 | + 'sh_latn' => 'srpskohrvastski', |
|
| 177 | + 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | + 'si' => 'Sinhalese', |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | + 'sm' => 'Samoan', |
|
| 182 | + 'sn' => 'Shona', |
|
| 183 | + 'so' => 'Somali', |
|
| 184 | + 'sq' => 'shqip', |
|
| 185 | + 'sr' => 'српски', |
|
| 186 | + 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | + 'sro' => 'sardu campidanésu', |
|
| 188 | + 'ss' => 'Siswati', |
|
| 189 | + 'st' => 'Sesotho', |
|
| 190 | + 'su' => 'Sundanese', |
|
| 191 | + 'sv' => 'svenska', |
|
| 192 | + 'sw' => 'Kiswahili', |
|
| 193 | + 'ta' => 'தமிழ்', // Tamil |
|
| 194 | + 'te' => 'Telugu', |
|
| 195 | + 'tg' => 'Tajik', |
|
| 196 | + 'th' => 'ไทย', |
|
| 197 | + 'ti' => 'Tigrinya', |
|
| 198 | + 'tk' => 'Turkmen', |
|
| 199 | + 'tl' => 'Tagalog', |
|
| 200 | + 'tn' => 'Setswana', |
|
| 201 | + 'to' => 'Tonga', |
|
| 202 | + 'tr' => 'Türkçe', |
|
| 203 | + 'ts' => 'Tsonga', |
|
| 204 | + 'tt' => 'Татар', |
|
| 205 | + 'tw' => 'Twi', |
|
| 206 | + 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | + 'ug' => 'Uighur', |
|
| 208 | + 'uk' => 'українська', |
|
| 209 | + 'ur' => 'ٱردو', |
|
| 210 | + 'uz' => "O'zbekcha", |
|
| 211 | + 'vi' => 'Tiếng Việt', |
|
| 212 | + 'vo' => 'Volapuk', |
|
| 213 | + 'wa' => 'walon', |
|
| 214 | + 'wo' => 'Wolof', |
|
| 215 | + 'xh' => 'Xhosa', |
|
| 216 | + 'yi' => 'Yiddish', |
|
| 217 | + 'yo' => 'Yoruba', |
|
| 218 | + 'za' => 'Zhuang', |
|
| 219 | + 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | + 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | + 'zu' => 'Zulu' |
|
| 222 | 222 | |
| 223 | 223 | ]; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'cpf_dom' => 'Kreyòl', |
| 51 | 51 | 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
| 52 | 52 | 'cs' => 'čeština', |
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | 54 | 'da' => 'dansk', |
| 55 | 55 | 'de' => 'Deutsch', |
| 56 | 56 | 'dz' => 'Bhutani', |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | 'hi' => 'हिंदी', |
| 93 | 93 | 'hr' => 'hrvatski', |
| 94 | 94 | 'hu' => 'magyar', |
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 95 | + 'hy' => 'Հայերեն', // Arménien |
|
| 96 | 96 | 'ia' => 'Interlingua', |
| 97 | 97 | 'id' => 'Indonesia', |
| 98 | 98 | 'ie' => 'Interlingue', |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'ka' => 'ქართული', |
| 107 | 107 | 'kk' => 'қазақ тілі', // Kazakh |
| 108 | 108 | 'kl' => 'kalaallisut', |
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 109 | + 'km' => 'ភាសាខ្មែរ', // Khmer |
|
| 110 | 110 | 'kn' => 'Kannada', |
| 111 | 111 | 'ko' => '한국어', |
| 112 | 112 | 'kok' => 'कोंकणी', |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | 'sh_latn' => 'srpskohrvastski', |
| 177 | 177 | 'sh_cyrl' => 'Српскохрватски', |
| 178 | 178 | 'si' => 'Sinhalese', |
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | 181 | 'sm' => 'Samoan', |
| 182 | 182 | 'sn' => 'Shona', |
| 183 | 183 | 'so' => 'Somali', |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | ); |
| 87 | 87 | foreach ($s as $row) { |
| 88 | 88 | if (email_valide($row['email'])) { |
| 89 | - $r .= ', ' . $row['email']; |
|
| 89 | + $r .= ', '.$row['email']; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | $args[2] = substr($r, 2); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * Pile complétée du code compilé |
| 41 | 41 | **/ |
| 42 | 42 | function balise_FORMULAIRE_ECRIRE_AUTEUR($p) { |
| 43 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 43 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -58,44 +58,44 @@ discard block |
||
| 58 | 58 | * - chaîne vide sinon (erreur ou non affichage). |
| 59 | 59 | */ |
| 60 | 60 | function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) { |
| 61 | - include_spip('inc/filtres'); |
|
| 62 | - // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 63 | - $id = (int) $args[1]; |
|
| 64 | - if (!$args[0] && !$id) { |
|
| 65 | - $msg = [ |
|
| 66 | - 'zbug_champ_hors_motif', |
|
| 67 | - [ |
|
| 68 | - 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 69 | - 'motif' => 'AUTEURS/ARTICLES' |
|
| 70 | - ] |
|
| 71 | - ]; |
|
| 61 | + include_spip('inc/filtres'); |
|
| 62 | + // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 63 | + $id = (int) $args[1]; |
|
| 64 | + if (!$args[0] && !$id) { |
|
| 65 | + $msg = [ |
|
| 66 | + 'zbug_champ_hors_motif', |
|
| 67 | + [ |
|
| 68 | + 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 69 | + 'motif' => 'AUTEURS/ARTICLES' |
|
| 70 | + ] |
|
| 71 | + ]; |
|
| 72 | 72 | |
| 73 | - erreur_squelette($msg, $context_compil); |
|
| 73 | + erreur_squelette($msg, $context_compil); |
|
| 74 | 74 | |
| 75 | - return ''; |
|
| 76 | - } |
|
| 77 | - // Si on est dans un contexte article, |
|
| 78 | - // sortir tous les mails des auteurs de l'article |
|
| 79 | - if (!$args[0] && $id) { |
|
| 80 | - $r = ''; |
|
| 81 | - $s = sql_allfetsel( |
|
| 82 | - 'email', |
|
| 83 | - 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | - "A.email != '' AND L.id_objet=$id" |
|
| 85 | - ); |
|
| 86 | - foreach ($s as $row) { |
|
| 87 | - if (email_valide($row['email'])) { |
|
| 88 | - $r .= ', ' . $row['email']; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - $args[2] = substr($r, 2); |
|
| 92 | - } |
|
| 75 | + return ''; |
|
| 76 | + } |
|
| 77 | + // Si on est dans un contexte article, |
|
| 78 | + // sortir tous les mails des auteurs de l'article |
|
| 79 | + if (!$args[0] && $id) { |
|
| 80 | + $r = ''; |
|
| 81 | + $s = sql_allfetsel( |
|
| 82 | + 'email', |
|
| 83 | + 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | + "A.email != '' AND L.id_objet=$id" |
|
| 85 | + ); |
|
| 86 | + foreach ($s as $row) { |
|
| 87 | + if (email_valide($row['email'])) { |
|
| 88 | + $r .= ', ' . $row['email']; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + $args[2] = substr($r, 2); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 95 | - if (!$args[2] || !email_valide($args[2])) { |
|
| 96 | - return ''; |
|
| 97 | - } |
|
| 94 | + // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 95 | + if (!$args[2] || !email_valide($args[2])) { |
|
| 96 | + return ''; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - // OK |
|
| 100 | - return $args; |
|
| 99 | + // OK |
|
| 100 | + return $args; |
|
| 101 | 101 | } |
@@ -11,134 +11,134 @@ |
||
| 11 | 11 | // plage invalide en iso-8859-1 mais souvent utilisee quand meme (windows) |
| 12 | 12 | // cf. http://openweb.eu.org/articles/caracteres_illegaux/ |
| 13 | 13 | // voir aussi copie de ces valeurs dans inc/charsets.php |
| 14 | - 128 => 8364, |
|
| 15 | - 129 => 129 /* ?? */, |
|
| 16 | - 130 => 8218, |
|
| 17 | - 131 => 402, |
|
| 18 | - 132 => 8222, |
|
| 19 | - 133 => 8230, |
|
| 20 | - 134 => 8224, |
|
| 21 | - 135 => 8225, |
|
| 22 | - 136 => 710, |
|
| 23 | - 137 => 8240, |
|
| 24 | - 138 => 352, |
|
| 25 | - 139 => 8249, |
|
| 26 | - 140 => 338, |
|
| 27 | - 141 => 141 /* ?? */, |
|
| 28 | - 142 => 381, |
|
| 29 | - 143 => 143 /* ?? */, |
|
| 30 | - 144 => 144 /* ?? */, |
|
| 31 | - 145 => 8216, |
|
| 32 | - 146 => 8217, |
|
| 33 | - 147 => 8220, |
|
| 34 | - 148 => 8221, |
|
| 35 | - 149 => 8226, |
|
| 36 | - 150 => 8211, |
|
| 37 | - 151 => 8212, |
|
| 38 | - 152 => 732, |
|
| 39 | - 153 => 8482, |
|
| 40 | - 154 => 353, |
|
| 41 | - 155 => 8250, |
|
| 42 | - 156 => 339, |
|
| 43 | - 157 => 157 /* ?? */, |
|
| 44 | - 158 => 382, |
|
| 45 | - 159 => 376, |
|
| 14 | + 128 => 8364, |
|
| 15 | + 129 => 129 /* ?? */, |
|
| 16 | + 130 => 8218, |
|
| 17 | + 131 => 402, |
|
| 18 | + 132 => 8222, |
|
| 19 | + 133 => 8230, |
|
| 20 | + 134 => 8224, |
|
| 21 | + 135 => 8225, |
|
| 22 | + 136 => 710, |
|
| 23 | + 137 => 8240, |
|
| 24 | + 138 => 352, |
|
| 25 | + 139 => 8249, |
|
| 26 | + 140 => 338, |
|
| 27 | + 141 => 141 /* ?? */, |
|
| 28 | + 142 => 381, |
|
| 29 | + 143 => 143 /* ?? */, |
|
| 30 | + 144 => 144 /* ?? */, |
|
| 31 | + 145 => 8216, |
|
| 32 | + 146 => 8217, |
|
| 33 | + 147 => 8220, |
|
| 34 | + 148 => 8221, |
|
| 35 | + 149 => 8226, |
|
| 36 | + 150 => 8211, |
|
| 37 | + 151 => 8212, |
|
| 38 | + 152 => 732, |
|
| 39 | + 153 => 8482, |
|
| 40 | + 154 => 353, |
|
| 41 | + 155 => 8250, |
|
| 42 | + 156 => 339, |
|
| 43 | + 157 => 157 /* ?? */, |
|
| 44 | + 158 => 382, |
|
| 45 | + 159 => 376, |
|
| 46 | 46 | |
| 47 | - 160 => 160, |
|
| 48 | - 161 => 161, |
|
| 49 | - 162 => 162, |
|
| 50 | - 163 => 163, |
|
| 51 | - 164 => 164, |
|
| 52 | - 165 => 165, |
|
| 53 | - 166 => 166, |
|
| 54 | - 167 => 167, |
|
| 55 | - 168 => 168, |
|
| 56 | - 169 => 169, |
|
| 57 | - 170 => 170, |
|
| 58 | - 171 => 171, |
|
| 59 | - 172 => 172, |
|
| 60 | - 173 => 173, |
|
| 61 | - 174 => 174, |
|
| 62 | - 175 => 175, |
|
| 63 | - 176 => 176, |
|
| 64 | - 177 => 177, |
|
| 65 | - 178 => 178, |
|
| 66 | - 179 => 179, |
|
| 67 | - 180 => 180, |
|
| 68 | - 181 => 181, |
|
| 69 | - 182 => 182, |
|
| 70 | - 183 => 183, |
|
| 71 | - 184 => 184, |
|
| 72 | - 185 => 185, |
|
| 73 | - 186 => 186, |
|
| 74 | - 187 => 187, |
|
| 75 | - 188 => 188, |
|
| 76 | - 189 => 189, |
|
| 77 | - 190 => 190, |
|
| 78 | - 191 => 191, |
|
| 79 | - 192 => 192, |
|
| 80 | - 193 => 193, |
|
| 81 | - 194 => 194, |
|
| 82 | - 195 => 195, |
|
| 83 | - 196 => 196, |
|
| 84 | - 197 => 197, |
|
| 85 | - 198 => 198, |
|
| 86 | - 199 => 199, |
|
| 87 | - 200 => 200, |
|
| 88 | - 201 => 201, |
|
| 89 | - 202 => 202, |
|
| 90 | - 203 => 203, |
|
| 91 | - 204 => 204, |
|
| 92 | - 205 => 205, |
|
| 93 | - 206 => 206, |
|
| 94 | - 207 => 207, |
|
| 95 | - 208 => 208, |
|
| 96 | - 209 => 209, |
|
| 97 | - 210 => 210, |
|
| 98 | - 211 => 211, |
|
| 99 | - 212 => 212, |
|
| 100 | - 213 => 213, |
|
| 101 | - 214 => 214, |
|
| 102 | - 215 => 215, |
|
| 103 | - 216 => 216, |
|
| 104 | - 217 => 217, |
|
| 105 | - 218 => 218, |
|
| 106 | - 219 => 219, |
|
| 107 | - 220 => 220, |
|
| 108 | - 221 => 221, |
|
| 109 | - 222 => 222, |
|
| 110 | - 223 => 223, |
|
| 111 | - 224 => 224, |
|
| 112 | - 225 => 225, |
|
| 113 | - 226 => 226, |
|
| 114 | - 227 => 227, |
|
| 115 | - 228 => 228, |
|
| 116 | - 229 => 229, |
|
| 117 | - 230 => 230, |
|
| 118 | - 231 => 231, |
|
| 119 | - 232 => 232, |
|
| 120 | - 233 => 233, |
|
| 121 | - 234 => 234, |
|
| 122 | - 235 => 235, |
|
| 123 | - 236 => 236, |
|
| 124 | - 237 => 237, |
|
| 125 | - 238 => 238, |
|
| 126 | - 239 => 239, |
|
| 127 | - 240 => 240, |
|
| 128 | - 241 => 241, |
|
| 129 | - 242 => 242, |
|
| 130 | - 243 => 243, |
|
| 131 | - 244 => 244, |
|
| 132 | - 245 => 245, |
|
| 133 | - 246 => 246, |
|
| 134 | - 247 => 247, |
|
| 135 | - 248 => 248, |
|
| 136 | - 249 => 249, |
|
| 137 | - 250 => 250, |
|
| 138 | - 251 => 251, |
|
| 139 | - 252 => 252, |
|
| 140 | - 253 => 253, |
|
| 141 | - 254 => 254, |
|
| 142 | - 255 => 255 |
|
| 47 | + 160 => 160, |
|
| 48 | + 161 => 161, |
|
| 49 | + 162 => 162, |
|
| 50 | + 163 => 163, |
|
| 51 | + 164 => 164, |
|
| 52 | + 165 => 165, |
|
| 53 | + 166 => 166, |
|
| 54 | + 167 => 167, |
|
| 55 | + 168 => 168, |
|
| 56 | + 169 => 169, |
|
| 57 | + 170 => 170, |
|
| 58 | + 171 => 171, |
|
| 59 | + 172 => 172, |
|
| 60 | + 173 => 173, |
|
| 61 | + 174 => 174, |
|
| 62 | + 175 => 175, |
|
| 63 | + 176 => 176, |
|
| 64 | + 177 => 177, |
|
| 65 | + 178 => 178, |
|
| 66 | + 179 => 179, |
|
| 67 | + 180 => 180, |
|
| 68 | + 181 => 181, |
|
| 69 | + 182 => 182, |
|
| 70 | + 183 => 183, |
|
| 71 | + 184 => 184, |
|
| 72 | + 185 => 185, |
|
| 73 | + 186 => 186, |
|
| 74 | + 187 => 187, |
|
| 75 | + 188 => 188, |
|
| 76 | + 189 => 189, |
|
| 77 | + 190 => 190, |
|
| 78 | + 191 => 191, |
|
| 79 | + 192 => 192, |
|
| 80 | + 193 => 193, |
|
| 81 | + 194 => 194, |
|
| 82 | + 195 => 195, |
|
| 83 | + 196 => 196, |
|
| 84 | + 197 => 197, |
|
| 85 | + 198 => 198, |
|
| 86 | + 199 => 199, |
|
| 87 | + 200 => 200, |
|
| 88 | + 201 => 201, |
|
| 89 | + 202 => 202, |
|
| 90 | + 203 => 203, |
|
| 91 | + 204 => 204, |
|
| 92 | + 205 => 205, |
|
| 93 | + 206 => 206, |
|
| 94 | + 207 => 207, |
|
| 95 | + 208 => 208, |
|
| 96 | + 209 => 209, |
|
| 97 | + 210 => 210, |
|
| 98 | + 211 => 211, |
|
| 99 | + 212 => 212, |
|
| 100 | + 213 => 213, |
|
| 101 | + 214 => 214, |
|
| 102 | + 215 => 215, |
|
| 103 | + 216 => 216, |
|
| 104 | + 217 => 217, |
|
| 105 | + 218 => 218, |
|
| 106 | + 219 => 219, |
|
| 107 | + 220 => 220, |
|
| 108 | + 221 => 221, |
|
| 109 | + 222 => 222, |
|
| 110 | + 223 => 223, |
|
| 111 | + 224 => 224, |
|
| 112 | + 225 => 225, |
|
| 113 | + 226 => 226, |
|
| 114 | + 227 => 227, |
|
| 115 | + 228 => 228, |
|
| 116 | + 229 => 229, |
|
| 117 | + 230 => 230, |
|
| 118 | + 231 => 231, |
|
| 119 | + 232 => 232, |
|
| 120 | + 233 => 233, |
|
| 121 | + 234 => 234, |
|
| 122 | + 235 => 235, |
|
| 123 | + 236 => 236, |
|
| 124 | + 237 => 237, |
|
| 125 | + 238 => 238, |
|
| 126 | + 239 => 239, |
|
| 127 | + 240 => 240, |
|
| 128 | + 241 => 241, |
|
| 129 | + 242 => 242, |
|
| 130 | + 243 => 243, |
|
| 131 | + 244 => 244, |
|
| 132 | + 245 => 245, |
|
| 133 | + 246 => 246, |
|
| 134 | + 247 => 247, |
|
| 135 | + 248 => 248, |
|
| 136 | + 249 => 249, |
|
| 137 | + 250 => 250, |
|
| 138 | + 251 => 251, |
|
| 139 | + 252 => 252, |
|
| 140 | + 253 => 253, |
|
| 141 | + 254 => 254, |
|
| 142 | + 255 => 255 |
|
| 143 | 143 | |
| 144 | 144 | ]; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | load_charset('iso-8859-1'); |
@@ -27,61 +27,61 @@ discard block |
||
| 27 | 27 | $trans = $GLOBALS['CHARSET']['iso-8859-1']; |
| 28 | 28 | |
| 29 | 29 | $mod = [ |
| 30 | - 0xA0 => 0x00A0, |
|
| 31 | - 0xA4 => 0x00A4, |
|
| 32 | - 0xAC => 0x060C, |
|
| 33 | - 0xAD => 0x00AD, |
|
| 34 | - 0xBB => 0x061B, |
|
| 35 | - 0xBF => 0x061F, |
|
| 36 | - 0xC1 => 0x0621, |
|
| 37 | - 0xC2 => 0x0622, |
|
| 38 | - 0xC3 => 0x0623, |
|
| 39 | - 0xC4 => 0x0624, |
|
| 40 | - 0xC5 => 0x0625, |
|
| 41 | - 0xC6 => 0x0626, |
|
| 42 | - 0xC7 => 0x0627, |
|
| 43 | - 0xC8 => 0x0628, |
|
| 44 | - 0xC9 => 0x0629, |
|
| 45 | - 0xCA => 0x062A, |
|
| 46 | - 0xCB => 0x062B, |
|
| 47 | - 0xCC => 0x062C, |
|
| 48 | - 0xCD => 0x062D, |
|
| 49 | - 0xCE => 0x062E, |
|
| 50 | - 0xCF => 0x062F, |
|
| 51 | - 0xD0 => 0x0630, |
|
| 52 | - 0xD1 => 0x0631, |
|
| 53 | - 0xD2 => 0x0632, |
|
| 54 | - 0xD3 => 0x0633, |
|
| 55 | - 0xD4 => 0x0634, |
|
| 56 | - 0xD5 => 0x0635, |
|
| 57 | - 0xD6 => 0x0636, |
|
| 58 | - 0xD7 => 0x0637, |
|
| 59 | - 0xD8 => 0x0638, |
|
| 60 | - 0xD9 => 0x0639, |
|
| 61 | - 0xDA => 0x063A, |
|
| 62 | - 0xE0 => 0x0640, |
|
| 63 | - 0xE1 => 0x0641, |
|
| 64 | - 0xE2 => 0x0642, |
|
| 65 | - 0xE3 => 0x0643, |
|
| 66 | - 0xE4 => 0x0644, |
|
| 67 | - 0xE5 => 0x0645, |
|
| 68 | - 0xE6 => 0x0646, |
|
| 69 | - 0xE7 => 0x0647, |
|
| 70 | - 0xE8 => 0x0648, |
|
| 71 | - 0xE9 => 0x0649, |
|
| 72 | - 0xEA => 0x064A, |
|
| 73 | - 0xEB => 0x064B, |
|
| 74 | - 0xEC => 0x064C, |
|
| 75 | - 0xED => 0x064D, |
|
| 76 | - 0xEE => 0x064E, |
|
| 77 | - 0xEF => 0x064F, |
|
| 78 | - 0xF0 => 0x0650, |
|
| 79 | - 0xF1 => 0x0651, |
|
| 80 | - 0xF2 => 0x0652 |
|
| 30 | + 0xA0 => 0x00A0, |
|
| 31 | + 0xA4 => 0x00A4, |
|
| 32 | + 0xAC => 0x060C, |
|
| 33 | + 0xAD => 0x00AD, |
|
| 34 | + 0xBB => 0x061B, |
|
| 35 | + 0xBF => 0x061F, |
|
| 36 | + 0xC1 => 0x0621, |
|
| 37 | + 0xC2 => 0x0622, |
|
| 38 | + 0xC3 => 0x0623, |
|
| 39 | + 0xC4 => 0x0624, |
|
| 40 | + 0xC5 => 0x0625, |
|
| 41 | + 0xC6 => 0x0626, |
|
| 42 | + 0xC7 => 0x0627, |
|
| 43 | + 0xC8 => 0x0628, |
|
| 44 | + 0xC9 => 0x0629, |
|
| 45 | + 0xCA => 0x062A, |
|
| 46 | + 0xCB => 0x062B, |
|
| 47 | + 0xCC => 0x062C, |
|
| 48 | + 0xCD => 0x062D, |
|
| 49 | + 0xCE => 0x062E, |
|
| 50 | + 0xCF => 0x062F, |
|
| 51 | + 0xD0 => 0x0630, |
|
| 52 | + 0xD1 => 0x0631, |
|
| 53 | + 0xD2 => 0x0632, |
|
| 54 | + 0xD3 => 0x0633, |
|
| 55 | + 0xD4 => 0x0634, |
|
| 56 | + 0xD5 => 0x0635, |
|
| 57 | + 0xD6 => 0x0636, |
|
| 58 | + 0xD7 => 0x0637, |
|
| 59 | + 0xD8 => 0x0638, |
|
| 60 | + 0xD9 => 0x0639, |
|
| 61 | + 0xDA => 0x063A, |
|
| 62 | + 0xE0 => 0x0640, |
|
| 63 | + 0xE1 => 0x0641, |
|
| 64 | + 0xE2 => 0x0642, |
|
| 65 | + 0xE3 => 0x0643, |
|
| 66 | + 0xE4 => 0x0644, |
|
| 67 | + 0xE5 => 0x0645, |
|
| 68 | + 0xE6 => 0x0646, |
|
| 69 | + 0xE7 => 0x0647, |
|
| 70 | + 0xE8 => 0x0648, |
|
| 71 | + 0xE9 => 0x0649, |
|
| 72 | + 0xEA => 0x064A, |
|
| 73 | + 0xEB => 0x064B, |
|
| 74 | + 0xEC => 0x064C, |
|
| 75 | + 0xED => 0x064D, |
|
| 76 | + 0xEE => 0x064E, |
|
| 77 | + 0xEF => 0x064F, |
|
| 78 | + 0xF0 => 0x0650, |
|
| 79 | + 0xF1 => 0x0651, |
|
| 80 | + 0xF2 => 0x0652 |
|
| 81 | 81 | ]; |
| 82 | 82 | |
| 83 | 83 | foreach ($mod as $num => $val) { |
| 84 | - $trans[$num] = $val; |
|
| 84 | + $trans[$num] = $val; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $GLOBALS['CHARSET']['iso-8859-6'] = $trans; |