@@ -64,13 +64,13 @@ |
||
| 64 | 64 | spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
| 65 | 65 | foreach ($desc['field'] as $field => $type) { |
| 66 | 66 | if ($desc['field'][$field] !== $fields_corrected[$field]) { |
| 67 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 68 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 67 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.'._LOG_INFO_IMPORTANTE); |
|
| 68 | + sql_alter("table $table change $field $field ".$fields_corrected[$field]); |
|
| 69 | 69 | $trouver_table(''); |
| 70 | 70 | $new_desc = $trouver_table($table); |
| 71 | 71 | spip_log( |
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 72 | + "Apres conversion $table : ".var_export($new_desc['field'], true), |
|
| 73 | + 'maj.'._LOG_INFO_IMPORTANTE |
|
| 74 | 74 | ); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @package SPIP\Core\SQL\Upgrade |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -34,49 +34,49 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function maj_timestamp_mysql($tables = null) { |
| 36 | 36 | |
| 37 | - include_spip('base/dump'); |
|
| 38 | - if (is_null($tables)) { |
|
| 39 | - $tables = base_lister_toutes_tables(); |
|
| 40 | - } elseif (is_string($tables)) { |
|
| 41 | - $tables = [$tables]; |
|
| 42 | - } elseif (!is_array($tables)) { |
|
| 43 | - return; |
|
| 44 | - } |
|
| 37 | + include_spip('base/dump'); |
|
| 38 | + if (is_null($tables)) { |
|
| 39 | + $tables = base_lister_toutes_tables(); |
|
| 40 | + } elseif (is_string($tables)) { |
|
| 41 | + $tables = [$tables]; |
|
| 42 | + } elseif (!is_array($tables)) { |
|
| 43 | + return; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // rien a faire si base non mysql |
|
| 47 | - if (!str_starts_with((string) $GLOBALS['connexions'][0]['type'], 'mysql')) { |
|
| 48 | - return; |
|
| 49 | - } |
|
| 46 | + // rien a faire si base non mysql |
|
| 47 | + if (!str_starts_with((string) $GLOBALS['connexions'][0]['type'], 'mysql')) { |
|
| 48 | + return; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 52 | - // forcer le vidage de cache |
|
| 53 | - $trouver_table(''); |
|
| 51 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 52 | + // forcer le vidage de cache |
|
| 53 | + $trouver_table(''); |
|
| 54 | 54 | |
| 55 | - foreach ($tables as $table) { |
|
| 56 | - if (time() >= _TIME_OUT) { |
|
| 57 | - return; |
|
| 58 | - } |
|
| 59 | - if ($desc = $trouver_table($table)) { |
|
| 60 | - $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 61 | - $d = array_diff($desc['field'], $fields_corrected); |
|
| 62 | - if ($d) { |
|
| 63 | - spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 64 | - foreach ($desc['field'] as $field => $type) { |
|
| 65 | - if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 66 | - spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 67 | - sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 68 | - $trouver_table(''); |
|
| 69 | - $new_desc = $trouver_table($table); |
|
| 70 | - spip_log( |
|
| 71 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 72 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 55 | + foreach ($tables as $table) { |
|
| 56 | + if (time() >= _TIME_OUT) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 59 | + if ($desc = $trouver_table($table)) { |
|
| 60 | + $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 61 | + $d = array_diff($desc['field'], $fields_corrected); |
|
| 62 | + if ($d) { |
|
| 63 | + spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 64 | + foreach ($desc['field'] as $field => $type) { |
|
| 65 | + if ($desc['field'][$field] !== $fields_corrected[$field]) { |
|
| 66 | + spip_log("Adaptation TIMESTAMP table $table", 'maj.' . _LOG_INFO_IMPORTANTE); |
|
| 67 | + sql_alter("table $table change $field $field " . $fields_corrected[$field]); |
|
| 68 | + $trouver_table(''); |
|
| 69 | + $new_desc = $trouver_table($table); |
|
| 70 | + spip_log( |
|
| 71 | + "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 72 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - // forcer le vidage de cache |
|
| 81 | - $trouver_table(''); |
|
| 80 | + // forcer le vidage de cache |
|
| 81 | + $trouver_table(''); |
|
| 82 | 82 | } |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('maj/legacy/v30'); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | #if (!$sql_desc) $sql_desc = false; |
| 86 | 86 | #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
| 87 | 87 | if (!$sql_desc) { |
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 88 | + spip_log("Echec creation table $table", 'maj'._LOG_CRITIQUE); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | if (isset($desc['field'])) { |
| 98 | 98 | foreach ($desc['field'] as $field => $type) { |
| 99 | 99 | if (!isset($sql_desc['field'][$field])) { |
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 100 | + sql_alter("TABLE $table ADD $field $type".($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | 101 | } |
| 102 | 102 | $last = $field; |
| 103 | 103 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Installation |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/acces'); |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | * @return bool |
| 33 | 33 | */ |
| 34 | 34 | function base_determine_autoinc($table, $desc = []) { |
| 35 | - if (($t = lister_tables_principales()) && isset($t[$table])) { |
|
| 36 | - $autoinc = true; |
|
| 37 | - } elseif (($t = lister_tables_auxiliaires()) && isset($t[$table])) { |
|
| 38 | - $autoinc = false; |
|
| 39 | - } else { |
|
| 40 | - // essayer de faire au mieux ! |
|
| 41 | - $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 42 | - && !str_contains((string) $desc['key']['PRIMARY KEY'], ',') |
|
| 43 | - && !str_contains((string) $desc['field'][$desc['key']['PRIMARY KEY']], 'default')); |
|
| 44 | - } |
|
| 35 | + if (($t = lister_tables_principales()) && isset($t[$table])) { |
|
| 36 | + $autoinc = true; |
|
| 37 | + } elseif (($t = lister_tables_auxiliaires()) && isset($t[$table])) { |
|
| 38 | + $autoinc = false; |
|
| 39 | + } else { |
|
| 40 | + // essayer de faire au mieux ! |
|
| 41 | + $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 42 | + && !str_contains((string) $desc['key']['PRIMARY KEY'], ',') |
|
| 43 | + && !str_contains((string) $desc['field'][$desc['key']['PRIMARY KEY']], 'default')); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - return $autoinc; |
|
| 46 | + return $autoinc; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -60,58 +60,58 @@ discard block |
||
| 60 | 60 | * @return void |
| 61 | 61 | */ |
| 62 | 62 | function creer_ou_upgrader_table($table, $desc, $autoinc, $upgrade = false, $serveur = '') { |
| 63 | - #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 64 | - $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 65 | - #if (!$sql_desc) $sql_desc = false; |
|
| 66 | - #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 67 | - if (!$sql_desc) { |
|
| 68 | - if ($autoinc === 'auto') { |
|
| 69 | - $autoinc = base_determine_autoinc($table, $desc); |
|
| 70 | - } |
|
| 71 | - #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 72 | - if (isset($desc['field']) && isset($desc['key'])) { |
|
| 73 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 74 | - } |
|
| 75 | - // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 76 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 77 | - #if (!$sql_desc) $sql_desc = false; |
|
| 78 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 79 | - if (!$sql_desc) { |
|
| 80 | - // on retente avec un sleep ? |
|
| 81 | - sleep(1); |
|
| 82 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 83 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 84 | - #if (!$sql_desc) $sql_desc = false; |
|
| 85 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 86 | - if (!$sql_desc) { |
|
| 87 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - } else { |
|
| 91 | - #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 92 | - // ajouter les champs manquants |
|
| 93 | - // on ne supprime jamais les champs, car c'est dangereux |
|
| 94 | - // c'est toujours a faire manuellement |
|
| 95 | - $last = ''; |
|
| 96 | - if (isset($desc['field'])) { |
|
| 97 | - foreach ($desc['field'] as $field => $type) { |
|
| 98 | - if (!isset($sql_desc['field'][$field])) { |
|
| 99 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 100 | - } |
|
| 101 | - $last = $field; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - if (isset($desc['key'])) { |
|
| 105 | - foreach ($desc['key'] as $key => $type) { |
|
| 106 | - // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 107 | - // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 108 | - if (!isset($sql_desc['key'][$key]) && !isset($sql_desc['key']["$key $type"])) { |
|
| 109 | - sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 110 | - } |
|
| 111 | - $last = $field; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 63 | + #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 64 | + $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 65 | + #if (!$sql_desc) $sql_desc = false; |
|
| 66 | + #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 67 | + if (!$sql_desc) { |
|
| 68 | + if ($autoinc === 'auto') { |
|
| 69 | + $autoinc = base_determine_autoinc($table, $desc); |
|
| 70 | + } |
|
| 71 | + #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 72 | + if (isset($desc['field']) && isset($desc['key'])) { |
|
| 73 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 74 | + } |
|
| 75 | + // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 76 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 77 | + #if (!$sql_desc) $sql_desc = false; |
|
| 78 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 79 | + if (!$sql_desc) { |
|
| 80 | + // on retente avec un sleep ? |
|
| 81 | + sleep(1); |
|
| 82 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 83 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 84 | + #if (!$sql_desc) $sql_desc = false; |
|
| 85 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 86 | + if (!$sql_desc) { |
|
| 87 | + spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + } else { |
|
| 91 | + #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 92 | + // ajouter les champs manquants |
|
| 93 | + // on ne supprime jamais les champs, car c'est dangereux |
|
| 94 | + // c'est toujours a faire manuellement |
|
| 95 | + $last = ''; |
|
| 96 | + if (isset($desc['field'])) { |
|
| 97 | + foreach ($desc['field'] as $field => $type) { |
|
| 98 | + if (!isset($sql_desc['field'][$field])) { |
|
| 99 | + sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 100 | + } |
|
| 101 | + $last = $field; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + if (isset($desc['key'])) { |
|
| 105 | + foreach ($desc['key'] as $key => $type) { |
|
| 106 | + // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 107 | + // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 108 | + if (!isset($sql_desc['key'][$key]) && !isset($sql_desc['key']["$key $type"])) { |
|
| 109 | + sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 110 | + } |
|
| 111 | + $last = $field; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -133,26 +133,26 @@ discard block |
||
| 133 | 133 | * @return void |
| 134 | 134 | */ |
| 135 | 135 | function alterer_base($tables_inc, $tables_noinc, $up = false, $serveur = '') { |
| 136 | - if ($up === false) { |
|
| 137 | - $old = false; |
|
| 138 | - $up = []; |
|
| 139 | - } else { |
|
| 140 | - $old = true; |
|
| 141 | - if (!is_array($up)) { |
|
| 142 | - $up = [$up]; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - foreach ($tables_inc as $k => $v) { |
|
| 146 | - if (!$old || in_array($k, $up)) { |
|
| 147 | - creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 148 | - } |
|
| 149 | - } |
|
| 136 | + if ($up === false) { |
|
| 137 | + $old = false; |
|
| 138 | + $up = []; |
|
| 139 | + } else { |
|
| 140 | + $old = true; |
|
| 141 | + if (!is_array($up)) { |
|
| 142 | + $up = [$up]; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + foreach ($tables_inc as $k => $v) { |
|
| 146 | + if (!$old || in_array($k, $up)) { |
|
| 147 | + creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - foreach ($tables_noinc as $k => $v) { |
|
| 152 | - if (!$old || in_array($k, $up)) { |
|
| 153 | - creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 154 | - } |
|
| 155 | - } |
|
| 151 | + foreach ($tables_noinc as $k => $v) { |
|
| 152 | + if (!$old || in_array($k, $up)) { |
|
| 153 | + creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -172,16 +172,16 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | function creer_base($serveur = '') { |
| 174 | 174 | |
| 175 | - // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 176 | - // de la conformite de la base |
|
| 177 | - // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 175 | + // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 176 | + // de la conformite de la base |
|
| 177 | + // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 178 | 178 | |
| 179 | - alterer_base( |
|
| 180 | - lister_tables_principales(), |
|
| 181 | - lister_tables_auxiliaires(), |
|
| 182 | - false, |
|
| 183 | - $serveur |
|
| 184 | - ); |
|
| 179 | + alterer_base( |
|
| 180 | + lister_tables_principales(), |
|
| 181 | + lister_tables_auxiliaires(), |
|
| 182 | + false, |
|
| 183 | + $serveur |
|
| 184 | + ); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | * @return void |
| 202 | 202 | */ |
| 203 | 203 | function maj_tables($upgrade_tables = [], $serveur = '') { |
| 204 | - alterer_base( |
|
| 205 | - lister_tables_principales(), |
|
| 206 | - lister_tables_auxiliaires(), |
|
| 207 | - $upgrade_tables, |
|
| 208 | - $serveur |
|
| 209 | - ); |
|
| 204 | + alterer_base( |
|
| 205 | + lister_tables_principales(), |
|
| 206 | + lister_tables_auxiliaires(), |
|
| 207 | + $upgrade_tables, |
|
| 208 | + $serveur |
|
| 209 | + ); |
|
| 210 | 210 | } |
@@ -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 | [ |
@@ -10,89 +10,89 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function install_etape_ldap1_dist() { |
| 17 | - $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 18 | - ? _INSTALL_HOST_LDAP |
|
| 19 | - : 'localhost'; |
|
| 17 | + $adresse_ldap = defined('_INSTALL_HOST_LDAP') |
|
| 18 | + ? _INSTALL_HOST_LDAP |
|
| 19 | + : 'localhost'; |
|
| 20 | 20 | |
| 21 | - $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 22 | - ? _INSTALL_PORT_LDAP |
|
| 23 | - : 389; |
|
| 21 | + $port_ldap = defined('_INSTALL_PORT_LDAP') |
|
| 22 | + ? _INSTALL_PORT_LDAP |
|
| 23 | + : 389; |
|
| 24 | 24 | |
| 25 | - $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 26 | - ? _INSTALL_TLS_LDAP |
|
| 27 | - : 'non'; |
|
| 25 | + $tls_ldap = defined('_INSTALL_TLS_LDAP') |
|
| 26 | + ? _INSTALL_TLS_LDAP |
|
| 27 | + : 'non'; |
|
| 28 | 28 | |
| 29 | - $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 30 | - ? _INSTALL_PROTOCOLE_LDAP |
|
| 31 | - : 3; // on essaie 2 en cas d'echec |
|
| 29 | + $protocole_ldap = defined('_INSTALL_PROTOCOLE_LDAP') |
|
| 30 | + ? _INSTALL_PROTOCOLE_LDAP |
|
| 31 | + : 3; // on essaie 2 en cas d'echec |
|
| 32 | 32 | |
| 33 | - $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 34 | - ? _INSTALL_USER_LDAP |
|
| 35 | - : ''; |
|
| 33 | + $login_ldap = defined('_INSTALL_USER_LDAP') |
|
| 34 | + ? _INSTALL_USER_LDAP |
|
| 35 | + : ''; |
|
| 36 | 36 | |
| 37 | - $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 38 | - ? _INSTALL_PASS_LDAP |
|
| 39 | - : ''; |
|
| 37 | + $pass_ldap = defined('_INSTALL_PASS_LDAP') |
|
| 38 | + ? _INSTALL_PASS_LDAP |
|
| 39 | + : ''; |
|
| 40 | 40 | |
| 41 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 42 | - echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 41 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 42 | + echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 43 | 43 | |
| 44 | - echo info_etape( |
|
| 45 | - _T('titre_connexion_ldap'), |
|
| 46 | - info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 47 | - ); |
|
| 44 | + echo info_etape( |
|
| 45 | + _T('titre_connexion_ldap'), |
|
| 46 | + info_progression_etape(1, 'etape_ldap', 'install/') |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | - echo generer_form_ecrire('install', ( |
|
| 50 | - "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 51 | - . fieldset( |
|
| 52 | - _T('entree_adresse_annuaire'), |
|
| 53 | - [ |
|
| 54 | - 'adresse_ldap' => [ |
|
| 55 | - 'label' => _T('texte_adresse_annuaire_1'), |
|
| 56 | - 'valeur' => $adresse_ldap |
|
| 57 | - ], |
|
| 58 | - 'port_ldap' => [ |
|
| 59 | - 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 60 | - 'valeur' => $port_ldap |
|
| 61 | - ], |
|
| 62 | - 'tls_ldap' => [ |
|
| 63 | - 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 64 | - 'valeur' => $tls_ldap, |
|
| 65 | - 'alternatives' => [ |
|
| 66 | - 'non' => _T('item_non'), |
|
| 67 | - 'oui' => _T('item_oui') |
|
| 68 | - ] |
|
| 69 | - ], |
|
| 70 | - 'protocole_ldap' => [ |
|
| 71 | - 'label' => _T('protocole_ldap'), |
|
| 72 | - 'valeur' => $protocole_ldap, |
|
| 73 | - 'alternatives' => [ |
|
| 74 | - '3' => '3', |
|
| 75 | - '2' => '2' |
|
| 76 | - ] |
|
| 77 | - ] |
|
| 78 | - ] |
|
| 79 | - ) |
|
| 49 | + echo generer_form_ecrire('install', ( |
|
| 50 | + "\n<input type='hidden' name='etape' value='ldap2' />" |
|
| 51 | + . fieldset( |
|
| 52 | + _T('entree_adresse_annuaire'), |
|
| 53 | + [ |
|
| 54 | + 'adresse_ldap' => [ |
|
| 55 | + 'label' => _T('texte_adresse_annuaire_1'), |
|
| 56 | + 'valeur' => $adresse_ldap |
|
| 57 | + ], |
|
| 58 | + 'port_ldap' => [ |
|
| 59 | + 'label' => _T('entree_port_annuaire') . '<br />' . _T('texte_port_annuaire'), |
|
| 60 | + 'valeur' => $port_ldap |
|
| 61 | + ], |
|
| 62 | + 'tls_ldap' => [ |
|
| 63 | + 'label' => '<b>' . _T('tls_ldap') . '</b>', |
|
| 64 | + 'valeur' => $tls_ldap, |
|
| 65 | + 'alternatives' => [ |
|
| 66 | + 'non' => _T('item_non'), |
|
| 67 | + 'oui' => _T('item_oui') |
|
| 68 | + ] |
|
| 69 | + ], |
|
| 70 | + 'protocole_ldap' => [ |
|
| 71 | + 'label' => _T('protocole_ldap'), |
|
| 72 | + 'valeur' => $protocole_ldap, |
|
| 73 | + 'alternatives' => [ |
|
| 74 | + '3' => '3', |
|
| 75 | + '2' => '2' |
|
| 76 | + ] |
|
| 77 | + ] |
|
| 78 | + ] |
|
| 79 | + ) |
|
| 80 | 80 | |
| 81 | - . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 82 | - . fieldset( |
|
| 83 | - _T('connexion_ldap'), |
|
| 84 | - [ |
|
| 85 | - 'login_ldap' => [ |
|
| 86 | - 'label' => _T('texte_login_ldap_1'), |
|
| 87 | - 'valeur' => $login_ldap |
|
| 88 | - ], |
|
| 89 | - 'pass_ldap' => [ |
|
| 90 | - 'label' => _T('entree_passe_ldap'), |
|
| 91 | - 'valeur' => $pass_ldap |
|
| 92 | - ] |
|
| 93 | - ] |
|
| 94 | - ) |
|
| 95 | - . bouton_suivant())); |
|
| 81 | + . "\n<p>" . _T('texte_acces_ldap_anonyme_1') . '</p>' |
|
| 82 | + . fieldset( |
|
| 83 | + _T('connexion_ldap'), |
|
| 84 | + [ |
|
| 85 | + 'login_ldap' => [ |
|
| 86 | + 'label' => _T('texte_login_ldap_1'), |
|
| 87 | + 'valeur' => $login_ldap |
|
| 88 | + ], |
|
| 89 | + 'pass_ldap' => [ |
|
| 90 | + 'label' => _T('entree_passe_ldap'), |
|
| 91 | + 'valeur' => $pass_ldap |
|
| 92 | + ] |
|
| 93 | + ] |
|
| 94 | + ) |
|
| 95 | + . bouton_suivant())); |
|
| 96 | 96 | |
| 97 | - echo $minipage->installFinPage(); |
|
| 97 | + echo $minipage->installFinPage(); |
|
| 98 | 98 | } |
@@ -561,11 +561,9 @@ discard block |
||
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
| 564 | - } |
|
| 565 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 564 | + } elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | 565 | $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
| 567 | - } |
|
| 568 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 566 | + } elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | 567 | $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
| 570 | 568 | } |
| 571 | 569 | } else { |
@@ -954,8 +952,7 @@ discard block |
||
| 954 | 952 | if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
| 955 | 953 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 954 | } |
| 957 | - } |
|
| 958 | - else { |
|
| 955 | + } else { |
|
| 959 | 956 | foreach ($info['chemin'] as $chemin) { |
| 960 | 957 | if ( |
| 961 | 958 | !isset($chemin['version']) or plugin_version_compatible( |
@@ -1425,8 +1422,7 @@ discard block |
||
| 1425 | 1422 | echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
| 1426 | 1423 | $trace, |
| 1427 | 1424 | "\n"; |
| 1428 | - } |
|
| 1429 | - else { |
|
| 1425 | + } else { |
|
| 1430 | 1426 | include_spip('inc/filtres_boites'); |
| 1431 | 1427 | echo "<div class='install-plugins svp_retour'>" |
| 1432 | 1428 | . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
@@ -1463,8 +1459,7 @@ discard block |
||
| 1463 | 1459 | if (file_exists($nom)) { |
| 1464 | 1460 | if (substr($nom, -4) == '.php') { |
| 1465 | 1461 | $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
| 1466 | - } |
|
| 1467 | - else { |
|
| 1462 | + } else { |
|
| 1468 | 1463 | $fichier_tmp = $nom . '.tmp'; |
| 1469 | 1464 | } |
| 1470 | 1465 | file_put_contents($fichier_tmp, $contenu); |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -47,27 +47,27 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | **/ |
| 49 | 49 | function liste_plugin_files($dir_plugins = null) { |
| 50 | - static $plugin_files = []; |
|
| 51 | - if (is_null($dir_plugins)) { |
|
| 52 | - $dir_plugins = _DIR_PLUGINS; |
|
| 53 | - } |
|
| 54 | - if ( |
|
| 55 | - !isset($plugin_files[$dir_plugins]) |
|
| 56 | - or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | - ) { |
|
| 58 | - $plugin_files[$dir_plugins] = []; |
|
| 59 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | - $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - sort($plugin_files[$dir_plugins]); |
|
| 64 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | - $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return $plugin_files[$dir_plugins]; |
|
| 50 | + static $plugin_files = []; |
|
| 51 | + if (is_null($dir_plugins)) { |
|
| 52 | + $dir_plugins = _DIR_PLUGINS; |
|
| 53 | + } |
|
| 54 | + if ( |
|
| 55 | + !isset($plugin_files[$dir_plugins]) |
|
| 56 | + or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | + ) { |
|
| 58 | + $plugin_files[$dir_plugins] = []; |
|
| 59 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | + $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + sort($plugin_files[$dir_plugins]); |
|
| 64 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | + $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return $plugin_files[$dir_plugins]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -83,45 +83,45 @@ discard block |
||
| 83 | 83 | * Liste complète des répeertoires |
| 84 | 84 | **/ |
| 85 | 85 | function fast_find_plugin_dirs($dir, $max_prof = 100) { |
| 86 | - $fichiers = []; |
|
| 87 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | - if ($dir == '') { |
|
| 91 | - $dir = '.'; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (!is_dir($dir)) { |
|
| 95 | - return $fichiers; |
|
| 96 | - } |
|
| 97 | - if (is_plugin_dir($dir, '')) { |
|
| 98 | - $fichiers[] = $dir; |
|
| 99 | - |
|
| 100 | - return $fichiers; |
|
| 101 | - } |
|
| 102 | - if ($max_prof <= 0) { |
|
| 103 | - return $fichiers; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $subdirs = []; |
|
| 107 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | - while (($f = readdir($d)) !== false) { |
|
| 109 | - if ( |
|
| 110 | - $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | - and $f != 'CVS' |
|
| 112 | - and is_dir($f = "$dir/$f") |
|
| 113 | - ) { |
|
| 114 | - $subdirs[] = $f; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - closedir($d); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - foreach ($subdirs as $d) { |
|
| 121 | - $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $fichiers; |
|
| 86 | + $fichiers = []; |
|
| 87 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | + if ($dir == '') { |
|
| 91 | + $dir = '.'; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (!is_dir($dir)) { |
|
| 95 | + return $fichiers; |
|
| 96 | + } |
|
| 97 | + if (is_plugin_dir($dir, '')) { |
|
| 98 | + $fichiers[] = $dir; |
|
| 99 | + |
|
| 100 | + return $fichiers; |
|
| 101 | + } |
|
| 102 | + if ($max_prof <= 0) { |
|
| 103 | + return $fichiers; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $subdirs = []; |
|
| 107 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | + while (($f = readdir($d)) !== false) { |
|
| 109 | + if ( |
|
| 110 | + $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | + and $f != 'CVS' |
|
| 112 | + and is_dir($f = "$dir/$f") |
|
| 113 | + ) { |
|
| 114 | + $subdirs[] = $f; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + closedir($d); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + foreach ($subdirs as $d) { |
|
| 121 | + $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $fichiers; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,27 +142,27 @@ discard block |
||
| 142 | 142 | **/ |
| 143 | 143 | function is_plugin_dir($dir, $dir_plugins = null) { |
| 144 | 144 | |
| 145 | - if (is_array($dir)) { |
|
| 146 | - foreach ($dir as $k => $d) { |
|
| 147 | - if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | - unset($dir[$k]); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $dir; |
|
| 153 | - } |
|
| 154 | - if (is_null($dir_plugins)) { |
|
| 155 | - $dir_plugins = _DIR_PLUGINS; |
|
| 156 | - } |
|
| 157 | - $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | - |
|
| 159 | - foreach ($search as $s) { |
|
| 160 | - if (file_exists($s)) { |
|
| 161 | - return $dir; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return ''; |
|
| 145 | + if (is_array($dir)) { |
|
| 146 | + foreach ($dir as $k => $d) { |
|
| 147 | + if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | + unset($dir[$k]); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $dir; |
|
| 153 | + } |
|
| 154 | + if (is_null($dir_plugins)) { |
|
| 155 | + $dir_plugins = _DIR_PLUGINS; |
|
| 156 | + } |
|
| 157 | + $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | + |
|
| 159 | + foreach ($search as $s) { |
|
| 160 | + if (file_exists($s)) { |
|
| 161 | + return $dir; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return ''; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** Regexp d'extraction des informations d'un intervalle de compatibilité */ |
@@ -189,51 +189,51 @@ discard block |
||
| 189 | 189 | **/ |
| 190 | 190 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 191 | 191 | |
| 192 | - if (!strlen($intervalle)) { |
|
| 193 | - return true; |
|
| 194 | - } |
|
| 195 | - if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | - $minimum = $regs[1]; |
|
| 201 | - $maximum = $regs[2]; |
|
| 202 | - |
|
| 203 | - // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | - // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | - // entre plugins) |
|
| 208 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | - if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | - return true; |
|
| 211 | - } |
|
| 212 | - // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | - // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $minimum_inc = $intervalle[0] == '['; |
|
| 217 | - $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | - |
|
| 219 | - if (strlen($minimum)) { |
|
| 220 | - if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | - return false; |
|
| 222 | - } |
|
| 223 | - if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | - return false; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - if (strlen($maximum)) { |
|
| 228 | - if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | - return false; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return true; |
|
| 192 | + if (!strlen($intervalle)) { |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 195 | + if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | + $minimum = $regs[1]; |
|
| 201 | + $maximum = $regs[2]; |
|
| 202 | + |
|
| 203 | + // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | + // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | + // entre plugins) |
|
| 208 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | + if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | + return true; |
|
| 211 | + } |
|
| 212 | + // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | + // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $minimum_inc = $intervalle[0] == '['; |
|
| 217 | + $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | + |
|
| 219 | + if (strlen($minimum)) { |
|
| 220 | + if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 223 | + if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + if (strlen($maximum)) { |
|
| 228 | + if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | + return false; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + return true; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -250,62 +250,62 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function liste_plugin_valides($liste_plug, $force = false) { |
| 253 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | - $infos = [ |
|
| 256 | - // lister les extensions qui sont automatiquement actives |
|
| 257 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | - ]; |
|
| 260 | - |
|
| 261 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | - $liste_non_classee = [ |
|
| 267 | - 'SPIP' => [ |
|
| 268 | - 'nom' => 'SPIP', |
|
| 269 | - 'etat' => 'stable', |
|
| 270 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | - 'dir' => '', |
|
| 273 | - ] |
|
| 274 | - ]; |
|
| 275 | - |
|
| 276 | - $invalides = []; |
|
| 277 | - foreach ($liste_ext as $plug) { |
|
| 278 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - foreach ($liste_plug as $plug) { |
|
| 283 | - if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | - if (is_array($r)) { |
|
| 286 | - $invalides = array_merge($invalides, $r); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | - foreach ($liste_plug as $plug) { |
|
| 294 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | - if (is_array($r)) { |
|
| 297 | - $invalides = array_merge($invalides, $r); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | - |
|
| 305 | - // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | - $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | - |
|
| 308 | - return [$infos, $liste_non_classee, $invalides]; |
|
| 253 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | + $infos = [ |
|
| 256 | + // lister les extensions qui sont automatiquement actives |
|
| 257 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | + ]; |
|
| 260 | + |
|
| 261 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | + $liste_non_classee = [ |
|
| 267 | + 'SPIP' => [ |
|
| 268 | + 'nom' => 'SPIP', |
|
| 269 | + 'etat' => 'stable', |
|
| 270 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | + 'dir' => '', |
|
| 273 | + ] |
|
| 274 | + ]; |
|
| 275 | + |
|
| 276 | + $invalides = []; |
|
| 277 | + foreach ($liste_ext as $plug) { |
|
| 278 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + foreach ($liste_plug as $plug) { |
|
| 283 | + if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | + if (is_array($r)) { |
|
| 286 | + $invalides = array_merge($invalides, $r); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | + foreach ($liste_plug as $plug) { |
|
| 294 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | + if (is_array($r)) { |
|
| 297 | + $invalides = array_merge($invalides, $r); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | + |
|
| 305 | + // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | + $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | + |
|
| 308 | + return [$infos, $liste_non_classee, $invalides]; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -325,38 +325,38 @@ discard block |
||
| 325 | 325 | * array description short si on ne le retient pas (pour memorisation dans une table des erreurs) |
| 326 | 326 | */ |
| 327 | 327 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) { |
| 328 | - $i = $infos[$dir_type][$plug]; |
|
| 329 | - // minimum syndical pour afficher si le xml avait des erreurs éventuelles |
|
| 330 | - $short_desc = [ |
|
| 331 | - 'dir' => $plug, |
|
| 332 | - 'dir_type' => $dir_type |
|
| 333 | - ]; |
|
| 334 | - if (empty($i['prefix'])) { |
|
| 335 | - // erreur xml ? mais sans connaissance du prefix, on retourne le chemin… |
|
| 336 | - $short_desc['erreur'] = $i['erreur'] ?? ['?']; |
|
| 337 | - return [$plug => $short_desc]; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $p = strtoupper($i['prefix']); |
|
| 341 | - $short_desc['nom'] = $i['nom']; |
|
| 342 | - $short_desc['etat'] = $i['etat']; |
|
| 343 | - $short_desc['version'] = $i['version']; |
|
| 344 | - |
|
| 345 | - if (isset($i['erreur']) and $i['erreur']) { |
|
| 346 | - $short_desc['erreur'] = $i['erreur']; |
|
| 347 | - return [$p => $short_desc]; |
|
| 348 | - } |
|
| 349 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 350 | - return [$p => $short_desc]; |
|
| 351 | - } |
|
| 352 | - if ( |
|
| 353 | - !isset($liste[$p]) |
|
| 354 | - or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 355 | - ) { |
|
| 356 | - $liste[$p] = $short_desc; |
|
| 357 | - } |
|
| 358 | - // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 359 | - return $p; |
|
| 328 | + $i = $infos[$dir_type][$plug]; |
|
| 329 | + // minimum syndical pour afficher si le xml avait des erreurs éventuelles |
|
| 330 | + $short_desc = [ |
|
| 331 | + 'dir' => $plug, |
|
| 332 | + 'dir_type' => $dir_type |
|
| 333 | + ]; |
|
| 334 | + if (empty($i['prefix'])) { |
|
| 335 | + // erreur xml ? mais sans connaissance du prefix, on retourne le chemin… |
|
| 336 | + $short_desc['erreur'] = $i['erreur'] ?? ['?']; |
|
| 337 | + return [$plug => $short_desc]; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $p = strtoupper($i['prefix']); |
|
| 341 | + $short_desc['nom'] = $i['nom']; |
|
| 342 | + $short_desc['etat'] = $i['etat']; |
|
| 343 | + $short_desc['version'] = $i['version']; |
|
| 344 | + |
|
| 345 | + if (isset($i['erreur']) and $i['erreur']) { |
|
| 346 | + $short_desc['erreur'] = $i['erreur']; |
|
| 347 | + return [$p => $short_desc]; |
|
| 348 | + } |
|
| 349 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 350 | + return [$p => $short_desc]; |
|
| 351 | + } |
|
| 352 | + if ( |
|
| 353 | + !isset($liste[$p]) |
|
| 354 | + or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 355 | + ) { |
|
| 356 | + $liste[$p] = $short_desc; |
|
| 357 | + } |
|
| 358 | + // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 359 | + return $p; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -372,47 +372,47 @@ discard block |
||
| 372 | 372 | * @param array $infos |
| 373 | 373 | */ |
| 374 | 374 | function plugin_fixer_procure(&$liste, &$infos) { |
| 375 | - foreach ($liste as $p => $resume) { |
|
| 376 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 377 | - if (isset($i['procure']) and $i['procure']) { |
|
| 378 | - foreach ($i['procure'] as $procure) { |
|
| 379 | - $p = strtoupper($procure['nom']); |
|
| 380 | - $dir = $resume['dir']; |
|
| 381 | - if ($dir) { |
|
| 382 | - $dir .= '/'; |
|
| 383 | - } |
|
| 384 | - $dir .= 'procure:' . $procure['nom']; |
|
| 385 | - |
|
| 386 | - $procure['etat'] = '?'; |
|
| 387 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 388 | - $procure['dir'] = $dir; |
|
| 389 | - |
|
| 390 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 391 | - // on ajoute cette version a la liste |
|
| 392 | - if ( |
|
| 393 | - !isset($liste[$p]) |
|
| 394 | - or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 395 | - ) { |
|
| 396 | - $liste[$p] = $procure; |
|
| 397 | - |
|
| 398 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 399 | - $infos[$resume['dir_type']][$dir] = [ |
|
| 400 | - 'prefix' => $procure['nom'], |
|
| 401 | - 'nom' => $procure['nom'], |
|
| 402 | - 'etat' => $procure['etat'], |
|
| 403 | - 'version' => $procure['version'], |
|
| 404 | - 'chemin' => [], |
|
| 405 | - 'necessite' => [], |
|
| 406 | - 'utilise' => [], |
|
| 407 | - 'lib' => [], |
|
| 408 | - 'menu' => [], |
|
| 409 | - 'onglet' => [], |
|
| 410 | - 'procure' => [], |
|
| 411 | - ]; |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - } |
|
| 375 | + foreach ($liste as $p => $resume) { |
|
| 376 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 377 | + if (isset($i['procure']) and $i['procure']) { |
|
| 378 | + foreach ($i['procure'] as $procure) { |
|
| 379 | + $p = strtoupper($procure['nom']); |
|
| 380 | + $dir = $resume['dir']; |
|
| 381 | + if ($dir) { |
|
| 382 | + $dir .= '/'; |
|
| 383 | + } |
|
| 384 | + $dir .= 'procure:' . $procure['nom']; |
|
| 385 | + |
|
| 386 | + $procure['etat'] = '?'; |
|
| 387 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 388 | + $procure['dir'] = $dir; |
|
| 389 | + |
|
| 390 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 391 | + // on ajoute cette version a la liste |
|
| 392 | + if ( |
|
| 393 | + !isset($liste[$p]) |
|
| 394 | + or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 395 | + ) { |
|
| 396 | + $liste[$p] = $procure; |
|
| 397 | + |
|
| 398 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 399 | + $infos[$resume['dir_type']][$dir] = [ |
|
| 400 | + 'prefix' => $procure['nom'], |
|
| 401 | + 'nom' => $procure['nom'], |
|
| 402 | + 'etat' => $procure['etat'], |
|
| 403 | + 'version' => $procure['version'], |
|
| 404 | + 'chemin' => [], |
|
| 405 | + 'necessite' => [], |
|
| 406 | + 'utilise' => [], |
|
| 407 | + 'lib' => [], |
|
| 408 | + 'menu' => [], |
|
| 409 | + 'onglet' => [], |
|
| 410 | + 'procure' => [], |
|
| 411 | + ]; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -426,20 +426,20 @@ discard block |
||
| 426 | 426 | * @return array |
| 427 | 427 | */ |
| 428 | 428 | function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) { |
| 429 | - foreach ($liste as $prefix => $infos) { |
|
| 430 | - if ( |
|
| 431 | - !$dir_plugins |
|
| 432 | - or ( |
|
| 433 | - defined($infos['dir_type']) |
|
| 434 | - and constant($infos['dir_type']) == $dir_plugins) |
|
| 435 | - ) { |
|
| 436 | - $liste[$prefix] = $infos['dir']; |
|
| 437 | - } else { |
|
| 438 | - unset($liste[$prefix]); |
|
| 439 | - } |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return $liste; |
|
| 429 | + foreach ($liste as $prefix => $infos) { |
|
| 430 | + if ( |
|
| 431 | + !$dir_plugins |
|
| 432 | + or ( |
|
| 433 | + defined($infos['dir_type']) |
|
| 434 | + and constant($infos['dir_type']) == $dir_plugins) |
|
| 435 | + ) { |
|
| 436 | + $liste[$prefix] = $infos['dir']; |
|
| 437 | + } else { |
|
| 438 | + unset($liste[$prefix]); |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return $liste; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -454,9 +454,9 @@ discard block |
||
| 454 | 454 | * @return array |
| 455 | 455 | */ |
| 456 | 456 | function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) { |
| 457 | - include_spip('plugins/installer'); |
|
| 457 | + include_spip('plugins/installer'); |
|
| 458 | 458 | |
| 459 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 459 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
@@ -487,54 +487,54 @@ discard block |
||
| 487 | 487 | * qui n'ont pas satisfait leurs dépendances |
| 488 | 488 | **/ |
| 489 | 489 | function plugin_trier($infos, $liste_non_classee) { |
| 490 | - $toute_la_liste = $liste_non_classee; |
|
| 491 | - $liste = $ordre = []; |
|
| 492 | - $count = 0; |
|
| 493 | - |
|
| 494 | - while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 495 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 496 | - $count = $c; |
|
| 497 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 498 | - $plug = $resume['dir']; |
|
| 499 | - $dir_type = $resume['dir_type']; |
|
| 500 | - $info1 = $infos[$dir_type][$plug]; |
|
| 501 | - // si des plugins sont necessaires, |
|
| 502 | - // on ne peut inserer qu'apres eux |
|
| 503 | - foreach ($info1['necessite'] as $need) { |
|
| 504 | - $nom = strtoupper($need['nom']); |
|
| 505 | - $compat = $need['compatibilite'] ?? ''; |
|
| 506 | - if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 507 | - $info1 = false; |
|
| 508 | - break; |
|
| 509 | - } |
|
| 510 | - } |
|
| 511 | - if (!$info1) { |
|
| 512 | - continue; |
|
| 513 | - } |
|
| 514 | - // idem si des plugins sont utiles, |
|
| 515 | - // sauf si ils sont de toute facon absents de la liste |
|
| 516 | - foreach ($info1['utilise'] as $need) { |
|
| 517 | - $nom = strtoupper($need['nom']); |
|
| 518 | - $compat = $need['compatibilite'] ?? ''; |
|
| 519 | - if (isset($toute_la_liste[$nom])) { |
|
| 520 | - if ( |
|
| 521 | - !isset($liste[$nom]) or |
|
| 522 | - !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 523 | - ) { |
|
| 524 | - $info1 = false; |
|
| 525 | - break; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - if ($info1) { |
|
| 530 | - $ordre[$p] = $info1; |
|
| 531 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 532 | - unset($liste_non_classee[$p]); |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - return [$liste, $ordre, $liste_non_classee]; |
|
| 490 | + $toute_la_liste = $liste_non_classee; |
|
| 491 | + $liste = $ordre = []; |
|
| 492 | + $count = 0; |
|
| 493 | + |
|
| 494 | + while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 495 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 496 | + $count = $c; |
|
| 497 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 498 | + $plug = $resume['dir']; |
|
| 499 | + $dir_type = $resume['dir_type']; |
|
| 500 | + $info1 = $infos[$dir_type][$plug]; |
|
| 501 | + // si des plugins sont necessaires, |
|
| 502 | + // on ne peut inserer qu'apres eux |
|
| 503 | + foreach ($info1['necessite'] as $need) { |
|
| 504 | + $nom = strtoupper($need['nom']); |
|
| 505 | + $compat = $need['compatibilite'] ?? ''; |
|
| 506 | + if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 507 | + $info1 = false; |
|
| 508 | + break; |
|
| 509 | + } |
|
| 510 | + } |
|
| 511 | + if (!$info1) { |
|
| 512 | + continue; |
|
| 513 | + } |
|
| 514 | + // idem si des plugins sont utiles, |
|
| 515 | + // sauf si ils sont de toute facon absents de la liste |
|
| 516 | + foreach ($info1['utilise'] as $need) { |
|
| 517 | + $nom = strtoupper($need['nom']); |
|
| 518 | + $compat = $need['compatibilite'] ?? ''; |
|
| 519 | + if (isset($toute_la_liste[$nom])) { |
|
| 520 | + if ( |
|
| 521 | + !isset($liste[$nom]) or |
|
| 522 | + !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 523 | + ) { |
|
| 524 | + $info1 = false; |
|
| 525 | + break; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | + if ($info1) { |
|
| 530 | + $ordre[$p] = $info1; |
|
| 531 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 532 | + unset($liste_non_classee[$p]); |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + return [$liste, $ordre, $liste_non_classee]; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -551,40 +551,40 @@ discard block |
||
| 551 | 551 | * Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent |
| 552 | 552 | **/ |
| 553 | 553 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) { |
| 554 | - static $erreurs = []; |
|
| 555 | - |
|
| 556 | - if (!is_array($liste)) { |
|
| 557 | - $liste = []; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 561 | - $liste = array_diff_key($liste, $liste_non_classee); |
|
| 562 | - |
|
| 563 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 564 | - $dir_type = $resume['dir_type']; |
|
| 565 | - $plug = $resume['dir']; |
|
| 566 | - $k = $infos[$dir_type][$plug]; |
|
| 567 | - |
|
| 568 | - $plug = constant($dir_type) . $plug; |
|
| 569 | - if (!isset($msg[$p])) { |
|
| 570 | - if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 571 | - $msg[$p] = [$resume['erreur']]; |
|
| 572 | - } |
|
| 573 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 574 | - $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 575 | - } |
|
| 576 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 577 | - $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 578 | - } |
|
| 579 | - } else { |
|
| 580 | - foreach ($msg[$p] as $c => $l) { |
|
| 581 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - $erreurs[$plug] = $msg[$p]; |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 554 | + static $erreurs = []; |
|
| 555 | + |
|
| 556 | + if (!is_array($liste)) { |
|
| 557 | + $liste = []; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 561 | + $liste = array_diff_key($liste, $liste_non_classee); |
|
| 562 | + |
|
| 563 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 564 | + $dir_type = $resume['dir_type']; |
|
| 565 | + $plug = $resume['dir']; |
|
| 566 | + $k = $infos[$dir_type][$plug]; |
|
| 567 | + |
|
| 568 | + $plug = constant($dir_type) . $plug; |
|
| 569 | + if (!isset($msg[$p])) { |
|
| 570 | + if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 571 | + $msg[$p] = [$resume['erreur']]; |
|
| 572 | + } |
|
| 573 | + elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 574 | + $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 575 | + } |
|
| 576 | + elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 577 | + $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 578 | + } |
|
| 579 | + } else { |
|
| 580 | + foreach ($msg[$p] as $c => $l) { |
|
| 581 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + $erreurs[$plug] = $msg[$p]; |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -599,25 +599,25 @@ discard block |
||
| 599 | 599 | * - Liste des erreurs ou code HTML des erreurs |
| 600 | 600 | **/ |
| 601 | 601 | function plugin_donne_erreurs($raw = false, $raz = true) { |
| 602 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 603 | - return $raw ? [] : ''; |
|
| 604 | - } |
|
| 605 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 606 | - // Compat ancienne version |
|
| 607 | - if (!$list) { |
|
| 608 | - $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 609 | - } elseif (!$raw) { |
|
| 610 | - foreach ($list as $plug => $msg) { |
|
| 611 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 613 | - } |
|
| 614 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 615 | - } |
|
| 616 | - if ($raz) { |
|
| 617 | - effacer_meta('plugin_erreur_activation'); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - return $list; |
|
| 602 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 603 | + return $raw ? [] : ''; |
|
| 604 | + } |
|
| 605 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 606 | + // Compat ancienne version |
|
| 607 | + if (!$list) { |
|
| 608 | + $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 609 | + } elseif (!$raw) { |
|
| 610 | + foreach ($list as $plug => $msg) { |
|
| 611 | + $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | + . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 613 | + } |
|
| 614 | + $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 615 | + } |
|
| 616 | + if ($raz) { |
|
| 617 | + effacer_meta('plugin_erreur_activation'); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + return $list; |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -637,21 +637,21 @@ discard block |
||
| 637 | 637 | * |
| 638 | 638 | **/ |
| 639 | 639 | function plugin_necessite($n, $liste, $balise = 'necessite') { |
| 640 | - $msg = []; |
|
| 641 | - foreach ($n as $need) { |
|
| 642 | - $id = strtoupper($need['nom']); |
|
| 643 | - $r = plugin_controler_necessite( |
|
| 644 | - $liste, |
|
| 645 | - $id, |
|
| 646 | - $need['compatibilite'] ?? '', |
|
| 647 | - $balise |
|
| 648 | - ); |
|
| 649 | - if ($r) { |
|
| 650 | - $msg[] = $r; |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - return $msg; |
|
| 640 | + $msg = []; |
|
| 641 | + foreach ($n as $need) { |
|
| 642 | + $id = strtoupper($need['nom']); |
|
| 643 | + $r = plugin_controler_necessite( |
|
| 644 | + $liste, |
|
| 645 | + $id, |
|
| 646 | + $need['compatibilite'] ?? '', |
|
| 647 | + $balise |
|
| 648 | + ); |
|
| 649 | + if ($r) { |
|
| 650 | + $msg[] = $r; |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + return $msg; |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -673,19 +673,19 @@ discard block |
||
| 673 | 673 | * Message d'erreur lorsque la dépendance est absente. |
| 674 | 674 | **/ |
| 675 | 675 | function plugin_controler_necessite($liste, $nom, $intervalle, $balise) { |
| 676 | - if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 677 | - return ''; |
|
| 678 | - } |
|
| 679 | - // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 680 | - if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 681 | - return ''; |
|
| 682 | - } |
|
| 683 | - return plugin_message_incompatibilite( |
|
| 684 | - $intervalle, |
|
| 685 | - (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 686 | - $nom, |
|
| 687 | - $balise |
|
| 688 | - ); |
|
| 676 | + if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 677 | + return ''; |
|
| 678 | + } |
|
| 679 | + // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 680 | + if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 681 | + return ''; |
|
| 682 | + } |
|
| 683 | + return plugin_message_incompatibilite( |
|
| 684 | + $intervalle, |
|
| 685 | + (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 686 | + $nom, |
|
| 687 | + $balise |
|
| 688 | + ); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -702,70 +702,70 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) { |
| 704 | 704 | |
| 705 | - // prendre en compte les erreurs de dépendances à PHP |
|
| 706 | - // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 707 | - $type = 'plugin'; |
|
| 708 | - if ($nom === 'SPIP') { |
|
| 709 | - $type = 'spip'; |
|
| 710 | - } elseif ($nom === 'PHP') { |
|
| 711 | - $type = 'php'; |
|
| 712 | - } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 713 | - $type = 'extension_php'; |
|
| 714 | - [, $nom] = explode(':', $nom, 2); |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 718 | - $minimum = $regs[1]; |
|
| 719 | - $maximum = $regs[2]; |
|
| 720 | - |
|
| 721 | - $minimum_inclus = $intervalle[0] == '['; |
|
| 722 | - $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 723 | - |
|
| 724 | - if (strlen($minimum)) { |
|
| 725 | - if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 726 | - return _T("plugin_{$balise}_{$type}", [ |
|
| 727 | - 'plugin' => $nom, |
|
| 728 | - 'version' => ' ≥ ' . $minimum |
|
| 729 | - ]); |
|
| 730 | - } |
|
| 731 | - if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 732 | - return _T("plugin_{$balise}_{$type}", [ |
|
| 733 | - 'plugin' => $nom, |
|
| 734 | - 'version' => ' > ' . $minimum |
|
| 735 | - ]); |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - if (strlen($maximum)) { |
|
| 740 | - if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 741 | - return _T("plugin_{$balise}_{$type}", [ |
|
| 742 | - 'plugin' => $nom, |
|
| 743 | - 'version' => ' ≤ ' . $maximum |
|
| 744 | - ]); |
|
| 745 | - } |
|
| 746 | - if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 747 | - return _T("plugin_{$balise}_plugin", [ |
|
| 748 | - 'plugin' => $nom, |
|
| 749 | - 'version' => ' < ' . $maximum |
|
| 750 | - ]); |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - // note : il ne peut pas y avoir d'erreur sur |
|
| 756 | - // - un 'utilise' sans version. |
|
| 757 | - // - un 'php' sans version. |
|
| 758 | - return _T("plugin_necessite_{$type}_sans_version", ['plugin' => $nom]); |
|
| 705 | + // prendre en compte les erreurs de dépendances à PHP |
|
| 706 | + // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 707 | + $type = 'plugin'; |
|
| 708 | + if ($nom === 'SPIP') { |
|
| 709 | + $type = 'spip'; |
|
| 710 | + } elseif ($nom === 'PHP') { |
|
| 711 | + $type = 'php'; |
|
| 712 | + } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 713 | + $type = 'extension_php'; |
|
| 714 | + [, $nom] = explode(':', $nom, 2); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 718 | + $minimum = $regs[1]; |
|
| 719 | + $maximum = $regs[2]; |
|
| 720 | + |
|
| 721 | + $minimum_inclus = $intervalle[0] == '['; |
|
| 722 | + $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 723 | + |
|
| 724 | + if (strlen($minimum)) { |
|
| 725 | + if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 726 | + return _T("plugin_{$balise}_{$type}", [ |
|
| 727 | + 'plugin' => $nom, |
|
| 728 | + 'version' => ' ≥ ' . $minimum |
|
| 729 | + ]); |
|
| 730 | + } |
|
| 731 | + if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 732 | + return _T("plugin_{$balise}_{$type}", [ |
|
| 733 | + 'plugin' => $nom, |
|
| 734 | + 'version' => ' > ' . $minimum |
|
| 735 | + ]); |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + if (strlen($maximum)) { |
|
| 740 | + if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 741 | + return _T("plugin_{$balise}_{$type}", [ |
|
| 742 | + 'plugin' => $nom, |
|
| 743 | + 'version' => ' ≤ ' . $maximum |
|
| 744 | + ]); |
|
| 745 | + } |
|
| 746 | + if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 747 | + return _T("plugin_{$balise}_plugin", [ |
|
| 748 | + 'plugin' => $nom, |
|
| 749 | + 'version' => ' < ' . $maximum |
|
| 750 | + ]); |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + // note : il ne peut pas y avoir d'erreur sur |
|
| 756 | + // - un 'utilise' sans version. |
|
| 757 | + // - un 'php' sans version. |
|
| 758 | + return _T("plugin_necessite_{$type}_sans_version", ['plugin' => $nom]); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | |
| 762 | 762 | function plugin_controler_lib($lib, $url) { |
| 763 | - /* Feature sortie du core, voir STP |
|
| 763 | + /* Feature sortie du core, voir STP |
|
| 764 | 764 | * if ($url) { |
| 765 | 765 | include_spip('inc/charger_plugin'); |
| 766 | 766 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 767 | 767 | }*/ |
| 768 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 768 | + return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * true si il y a eu des modifications sur la liste des plugins actifs, false sinon |
| 781 | 781 | **/ |
| 782 | 782 | function actualise_plugins_actifs($pipe_recherche = false) { |
| 783 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 783 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | |
@@ -807,116 +807,116 @@ discard block |
||
| 807 | 807 | **/ |
| 808 | 808 | function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') { |
| 809 | 809 | |
| 810 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 811 | - $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 812 | - |
|
| 813 | - // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 814 | - if (!$cache and !spip_connect()) { |
|
| 815 | - return false; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - if ($operation != 'raz') { |
|
| 819 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 820 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 821 | - if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 822 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 823 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 824 | - $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 825 | - } |
|
| 826 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 827 | - // on les reinjecte ici |
|
| 828 | - if ( |
|
| 829 | - isset($GLOBALS['meta']['plugin_attente']) |
|
| 830 | - and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 831 | - ) { |
|
| 832 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - if ($operation == 'ajoute') { |
|
| 836 | - $plugin = array_merge($plugin_valides, $plugin); |
|
| 837 | - } elseif ($operation == 'enleve') { |
|
| 838 | - $plugin = array_diff($plugin_valides, $plugin); |
|
| 839 | - } else { |
|
| 840 | - $plugin = $plugin_valides; |
|
| 841 | - } |
|
| 842 | - } |
|
| 843 | - $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 844 | - |
|
| 845 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 846 | - if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 847 | - $plugin = $ajouter_dependances($plugin); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - // recharger le xml des plugins a activer |
|
| 851 | - // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 852 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 853 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 854 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 855 | - [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 856 | - // trouver l'ordre d'activation |
|
| 857 | - [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 858 | - if ($invalides or $reste) { |
|
| 859 | - plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - // Ignorer les plugins necessitant une lib absente |
|
| 863 | - // et preparer la meta d'entete Http |
|
| 864 | - $err = $msg = $header = []; |
|
| 865 | - foreach ($plugin_valides as $p => $resume) { |
|
| 866 | - // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 867 | - if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') { |
|
| 868 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 869 | - } |
|
| 870 | - if ($resume['dir']) { |
|
| 871 | - foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 872 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 873 | - $err[$p] = $resume; |
|
| 874 | - $msg[$p][] = $l; |
|
| 875 | - unset($plugin_valides[$p]); |
|
| 876 | - } |
|
| 877 | - } |
|
| 878 | - } |
|
| 879 | - } |
|
| 880 | - if ($err) { |
|
| 881 | - plugins_erreurs($err, '', $infos, $msg); |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 885 | - effacer_meta('message_crash_plugins'); |
|
| 886 | - } |
|
| 887 | - ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 888 | - $liste = array_diff_key($liste, $plugin_valides); |
|
| 889 | - ecrire_meta('plugin_attente', serialize($liste)); |
|
| 890 | - $header = strtolower(implode(',', $header)); |
|
| 891 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 892 | - ecrire_fichier( |
|
| 893 | - _DIR_VAR . 'config.txt', |
|
| 894 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 895 | - ); |
|
| 896 | - } else { |
|
| 897 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 898 | - } |
|
| 899 | - // generer charger_plugins_chemin.php |
|
| 900 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 901 | - // generer les fichiers |
|
| 902 | - // - charger_plugins_options.php |
|
| 903 | - // - charger_plugins_fonctions.php |
|
| 904 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 905 | - // charger les chemins des plugins et les fichiers d'options |
|
| 906 | - // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 907 | - plugins_amorcer_plugins_actifs(); |
|
| 908 | - // mise a jour de la matrice des pipelines |
|
| 909 | - $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 910 | - // generer le fichier _CACHE_PIPELINE |
|
| 911 | - pipeline_precompile($prepend_code); |
|
| 912 | - |
|
| 913 | - if (spip_connect()) { |
|
| 914 | - // lancer et initialiser les nouveaux crons ! |
|
| 915 | - include_spip('inc/genie'); |
|
| 916 | - genie_queue_watch_dist(); |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 810 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 811 | + $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 812 | + |
|
| 813 | + // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 814 | + if (!$cache and !spip_connect()) { |
|
| 815 | + return false; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + if ($operation != 'raz') { |
|
| 819 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 820 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 821 | + if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 822 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 823 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 824 | + $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 825 | + } |
|
| 826 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 827 | + // on les reinjecte ici |
|
| 828 | + if ( |
|
| 829 | + isset($GLOBALS['meta']['plugin_attente']) |
|
| 830 | + and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 831 | + ) { |
|
| 832 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + if ($operation == 'ajoute') { |
|
| 836 | + $plugin = array_merge($plugin_valides, $plugin); |
|
| 837 | + } elseif ($operation == 'enleve') { |
|
| 838 | + $plugin = array_diff($plugin_valides, $plugin); |
|
| 839 | + } else { |
|
| 840 | + $plugin = $plugin_valides; |
|
| 841 | + } |
|
| 842 | + } |
|
| 843 | + $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 844 | + |
|
| 845 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 846 | + if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 847 | + $plugin = $ajouter_dependances($plugin); |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + // recharger le xml des plugins a activer |
|
| 851 | + // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 852 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 853 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 854 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 855 | + [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 856 | + // trouver l'ordre d'activation |
|
| 857 | + [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 858 | + if ($invalides or $reste) { |
|
| 859 | + plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + // Ignorer les plugins necessitant une lib absente |
|
| 863 | + // et preparer la meta d'entete Http |
|
| 864 | + $err = $msg = $header = []; |
|
| 865 | + foreach ($plugin_valides as $p => $resume) { |
|
| 866 | + // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 867 | + if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') { |
|
| 868 | + $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 869 | + } |
|
| 870 | + if ($resume['dir']) { |
|
| 871 | + foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 872 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 873 | + $err[$p] = $resume; |
|
| 874 | + $msg[$p][] = $l; |
|
| 875 | + unset($plugin_valides[$p]); |
|
| 876 | + } |
|
| 877 | + } |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | + if ($err) { |
|
| 881 | + plugins_erreurs($err, '', $infos, $msg); |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 885 | + effacer_meta('message_crash_plugins'); |
|
| 886 | + } |
|
| 887 | + ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 888 | + $liste = array_diff_key($liste, $plugin_valides); |
|
| 889 | + ecrire_meta('plugin_attente', serialize($liste)); |
|
| 890 | + $header = strtolower(implode(',', $header)); |
|
| 891 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 892 | + ecrire_fichier( |
|
| 893 | + _DIR_VAR . 'config.txt', |
|
| 894 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 895 | + ); |
|
| 896 | + } else { |
|
| 897 | + @unlink(_DIR_VAR . 'config.txt'); |
|
| 898 | + } |
|
| 899 | + // generer charger_plugins_chemin.php |
|
| 900 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 901 | + // generer les fichiers |
|
| 902 | + // - charger_plugins_options.php |
|
| 903 | + // - charger_plugins_fonctions.php |
|
| 904 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 905 | + // charger les chemins des plugins et les fichiers d'options |
|
| 906 | + // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 907 | + plugins_amorcer_plugins_actifs(); |
|
| 908 | + // mise a jour de la matrice des pipelines |
|
| 909 | + $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 910 | + // generer le fichier _CACHE_PIPELINE |
|
| 911 | + pipeline_precompile($prepend_code); |
|
| 912 | + |
|
| 913 | + if (spip_connect()) { |
|
| 914 | + // lancer et initialiser les nouveaux crons ! |
|
| 915 | + include_spip('inc/genie'); |
|
| 916 | + genie_queue_watch_dist(); |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -935,74 +935,74 @@ discard block |
||
| 935 | 935 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 936 | 936 | **/ |
| 937 | 937 | function plugins_precompile_chemin($plugin_valides, $ordre) { |
| 938 | - $chemins = [ |
|
| 939 | - 'public' => [], |
|
| 940 | - 'prive' => [] |
|
| 941 | - ]; |
|
| 942 | - $contenu = ''; |
|
| 943 | - foreach ($ordre as $p => $info) { |
|
| 944 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 945 | - if (isset($plugin_valides[$p])) { |
|
| 946 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 947 | - $plug = $plugin_valides[$p]['dir']; |
|
| 948 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 949 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 950 | - |
|
| 951 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 952 | - |
|
| 953 | - $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 954 | - if ( |
|
| 955 | - $prefix !== 'SPIP' |
|
| 956 | - and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 957 | - ) { |
|
| 958 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 959 | - if (!$info['chemin']) { |
|
| 960 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 961 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 962 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 963 | - $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 964 | - } |
|
| 965 | - } |
|
| 966 | - else { |
|
| 967 | - foreach ($info['chemin'] as $chemin) { |
|
| 968 | - if ( |
|
| 969 | - !isset($chemin['version']) or plugin_version_compatible( |
|
| 970 | - $chemin['version'], |
|
| 971 | - $GLOBALS['spip_version_branche'], |
|
| 972 | - 'spip' |
|
| 973 | - ) |
|
| 974 | - ) { |
|
| 975 | - $dir = $chemin['path']; |
|
| 976 | - if (strlen($dir) and $dir[0] == '/') { |
|
| 977 | - $dir = substr($dir, 1); |
|
| 978 | - } |
|
| 979 | - if (strlen($dir) and $dir == './') { |
|
| 980 | - $dir = ''; |
|
| 981 | - } |
|
| 982 | - if (strlen($dir)) { |
|
| 983 | - $dir = rtrim($dir, '/') . '/'; |
|
| 984 | - } |
|
| 985 | - if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 986 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | - } |
|
| 988 | - if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 989 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | - } |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - } |
|
| 994 | - } |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 998 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 999 | - ',', |
|
| 1000 | - array_reverse($chemins['public']) |
|
| 1001 | - ) . "]);\n" |
|
| 1002 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1003 | - } |
|
| 1004 | - |
|
| 1005 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 938 | + $chemins = [ |
|
| 939 | + 'public' => [], |
|
| 940 | + 'prive' => [] |
|
| 941 | + ]; |
|
| 942 | + $contenu = ''; |
|
| 943 | + foreach ($ordre as $p => $info) { |
|
| 944 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 945 | + if (isset($plugin_valides[$p])) { |
|
| 946 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 947 | + $plug = $plugin_valides[$p]['dir']; |
|
| 948 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 949 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 950 | + |
|
| 951 | + $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 952 | + |
|
| 953 | + $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 954 | + if ( |
|
| 955 | + $prefix !== 'SPIP' |
|
| 956 | + and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 957 | + ) { |
|
| 958 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 959 | + if (!$info['chemin']) { |
|
| 960 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 961 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 962 | + if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 963 | + $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 964 | + } |
|
| 965 | + } |
|
| 966 | + else { |
|
| 967 | + foreach ($info['chemin'] as $chemin) { |
|
| 968 | + if ( |
|
| 969 | + !isset($chemin['version']) or plugin_version_compatible( |
|
| 970 | + $chemin['version'], |
|
| 971 | + $GLOBALS['spip_version_branche'], |
|
| 972 | + 'spip' |
|
| 973 | + ) |
|
| 974 | + ) { |
|
| 975 | + $dir = $chemin['path']; |
|
| 976 | + if (strlen($dir) and $dir[0] == '/') { |
|
| 977 | + $dir = substr($dir, 1); |
|
| 978 | + } |
|
| 979 | + if (strlen($dir) and $dir == './') { |
|
| 980 | + $dir = ''; |
|
| 981 | + } |
|
| 982 | + if (strlen($dir)) { |
|
| 983 | + $dir = rtrim($dir, '/') . '/'; |
|
| 984 | + } |
|
| 985 | + if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 986 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | + } |
|
| 988 | + if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 989 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | + } |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + } |
|
| 994 | + } |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 998 | + $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 999 | + ',', |
|
| 1000 | + array_reverse($chemins['public']) |
|
| 1001 | + ) . "]);\n" |
|
| 1002 | + . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1003 | + } |
|
| 1004 | + |
|
| 1005 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /** |
@@ -1020,67 +1020,67 @@ discard block |
||
| 1020 | 1020 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 1021 | 1021 | **/ |
| 1022 | 1022 | function plugins_precompile_xxxtions($plugin_valides, $ordre) { |
| 1023 | - $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1024 | - $boutons = []; |
|
| 1025 | - $onglets = []; |
|
| 1026 | - $sign = ''; |
|
| 1027 | - |
|
| 1028 | - foreach ($ordre as $p => $info) { |
|
| 1029 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1030 | - if (isset($plugin_valides[$p])) { |
|
| 1031 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1032 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1033 | - $dir = constant($dir_type); |
|
| 1034 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1035 | - if ($info['menu']) { |
|
| 1036 | - $boutons = array_merge($boutons, $info['menu']); |
|
| 1037 | - } |
|
| 1038 | - if ($info['onglet']) { |
|
| 1039 | - $onglets = array_merge($onglets, $info['onglet']); |
|
| 1040 | - } |
|
| 1041 | - foreach ($contenu as $charge => $v) { |
|
| 1042 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1043 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1044 | - // donc ni sa relecture, ni sa detection |
|
| 1045 | - if ( |
|
| 1046 | - !isset($info[$charge]) |
|
| 1047 | - and $dir // exclure le cas du plugin "SPIP" |
|
| 1048 | - and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 1049 | - and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1050 | - ) { |
|
| 1051 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1052 | - $info[$charge] = [$file]; |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1055 | - if (isset($info[$charge])) { |
|
| 1056 | - $files = $info[$charge]; |
|
| 1057 | - foreach ($files as $k => $file) { |
|
| 1058 | - // on genere un if file_exists devant chaque include |
|
| 1059 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 1060 | - $file = trim($file); |
|
| 1061 | - if ( |
|
| 1062 | - !is_readable("$dir$plug/$file") |
|
| 1063 | - // uniquement pour les paquet.xml |
|
| 1064 | - and file_exists("$dir$plug/paquet.xml") |
|
| 1065 | - ) { |
|
| 1066 | - unset($info[$charge][$k]); |
|
| 1067 | - } else { |
|
| 1068 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1069 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1070 | - } |
|
| 1071 | - } |
|
| 1072 | - } |
|
| 1073 | - } |
|
| 1074 | - $sign .= md5(serialize($info)); |
|
| 1075 | - } |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1079 | - $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1080 | - . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1081 | - |
|
| 1082 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1083 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1023 | + $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1024 | + $boutons = []; |
|
| 1025 | + $onglets = []; |
|
| 1026 | + $sign = ''; |
|
| 1027 | + |
|
| 1028 | + foreach ($ordre as $p => $info) { |
|
| 1029 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1030 | + if (isset($plugin_valides[$p])) { |
|
| 1031 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1032 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1033 | + $dir = constant($dir_type); |
|
| 1034 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1035 | + if ($info['menu']) { |
|
| 1036 | + $boutons = array_merge($boutons, $info['menu']); |
|
| 1037 | + } |
|
| 1038 | + if ($info['onglet']) { |
|
| 1039 | + $onglets = array_merge($onglets, $info['onglet']); |
|
| 1040 | + } |
|
| 1041 | + foreach ($contenu as $charge => $v) { |
|
| 1042 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1043 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1044 | + // donc ni sa relecture, ni sa detection |
|
| 1045 | + if ( |
|
| 1046 | + !isset($info[$charge]) |
|
| 1047 | + and $dir // exclure le cas du plugin "SPIP" |
|
| 1048 | + and !str_contains($dir, ':') // exclure le cas des procure: |
|
| 1049 | + and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1050 | + ) { |
|
| 1051 | + if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1052 | + $info[$charge] = [$file]; |
|
| 1053 | + } |
|
| 1054 | + } |
|
| 1055 | + if (isset($info[$charge])) { |
|
| 1056 | + $files = $info[$charge]; |
|
| 1057 | + foreach ($files as $k => $file) { |
|
| 1058 | + // on genere un if file_exists devant chaque include |
|
| 1059 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 1060 | + $file = trim($file); |
|
| 1061 | + if ( |
|
| 1062 | + !is_readable("$dir$plug/$file") |
|
| 1063 | + // uniquement pour les paquet.xml |
|
| 1064 | + and file_exists("$dir$plug/paquet.xml") |
|
| 1065 | + ) { |
|
| 1066 | + unset($info[$charge][$k]); |
|
| 1067 | + } else { |
|
| 1068 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1069 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1070 | + } |
|
| 1071 | + } |
|
| 1072 | + } |
|
| 1073 | + } |
|
| 1074 | + $sign .= md5(serialize($info)); |
|
| 1075 | + } |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1079 | + $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1080 | + . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1081 | + |
|
| 1082 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1083 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
@@ -1099,24 +1099,24 @@ discard block |
||
| 1099 | 1099 | * @return string Code php |
| 1100 | 1100 | */ |
| 1101 | 1101 | function plugin_ongletbouton($nom, $val) { |
| 1102 | - if (!$val) { |
|
| 1103 | - $val = []; |
|
| 1104 | - } |
|
| 1105 | - |
|
| 1106 | - $val = serialize($val); |
|
| 1107 | - $md5 = md5($val); |
|
| 1108 | - |
|
| 1109 | - if (!defined("_UPDATED_$nom")) { |
|
| 1110 | - define("_UPDATED_$nom", $val); |
|
| 1111 | - define("_UPDATED_md5_$nom", $md5); |
|
| 1112 | - } |
|
| 1113 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1114 | - |
|
| 1115 | - return |
|
| 1116 | - "if (!function_exists('$nom')) {\n" |
|
| 1117 | - . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1118 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1119 | - . "}\n"; |
|
| 1102 | + if (!$val) { |
|
| 1103 | + $val = []; |
|
| 1104 | + } |
|
| 1105 | + |
|
| 1106 | + $val = serialize($val); |
|
| 1107 | + $md5 = md5($val); |
|
| 1108 | + |
|
| 1109 | + if (!defined("_UPDATED_$nom")) { |
|
| 1110 | + define("_UPDATED_$nom", $val); |
|
| 1111 | + define("_UPDATED_md5_$nom", $md5); |
|
| 1112 | + } |
|
| 1113 | + $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1114 | + |
|
| 1115 | + return |
|
| 1116 | + "if (!function_exists('$nom')) {\n" |
|
| 1117 | + . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1118 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1119 | + . "}\n"; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | /** |
@@ -1131,15 +1131,15 @@ discard block |
||
| 1131 | 1131 | **/ |
| 1132 | 1132 | function plugins_amorcer_plugins_actifs() { |
| 1133 | 1133 | |
| 1134 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1135 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1136 | - } |
|
| 1134 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1135 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1136 | + } |
|
| 1137 | 1137 | |
| 1138 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1139 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 1140 | - } else { |
|
| 1141 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1142 | - } |
|
| 1138 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1139 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 1140 | + } else { |
|
| 1141 | + spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1142 | + } |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
@@ -1162,140 +1162,140 @@ discard block |
||
| 1162 | 1162 | * Couples (nom du pipeline => Code PHP à insérer au début du pipeline) |
| 1163 | 1163 | **/ |
| 1164 | 1164 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) { |
| 1165 | - static $liste_pipe_manquants = []; |
|
| 1166 | - if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1167 | - $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - $prepend_code = []; |
|
| 1171 | - |
|
| 1172 | - foreach ($ordre as $p => $info) { |
|
| 1173 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1174 | - if (isset($plugin_valides[$p])) { |
|
| 1175 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1176 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1177 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1178 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1179 | - if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1180 | - foreach ($info['pipeline'] as $pipe) { |
|
| 1181 | - $nom = $pipe['nom']; |
|
| 1182 | - if (isset($pipe['action'])) { |
|
| 1183 | - $action = $pipe['action']; |
|
| 1184 | - } else { |
|
| 1185 | - $action = $nom; |
|
| 1186 | - } |
|
| 1187 | - $nomlower = strtolower($nom); |
|
| 1188 | - if ( |
|
| 1189 | - $nomlower != $nom |
|
| 1190 | - and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1191 | - and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1192 | - ) { |
|
| 1193 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1194 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1195 | - } |
|
| 1196 | - $nom = $nomlower; |
|
| 1197 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1198 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1199 | - $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1200 | - } |
|
| 1201 | - if ($action) { |
|
| 1202 | - if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1203 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1204 | - ',(\|\||$),', |
|
| 1205 | - "|$prefix$action\\1", |
|
| 1206 | - $GLOBALS['spip_pipeline'][$nom], |
|
| 1207 | - 1 |
|
| 1208 | - ); |
|
| 1209 | - } |
|
| 1210 | - if (isset($pipe['inclure'])) { |
|
| 1211 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1212 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1213 | - } |
|
| 1214 | - } |
|
| 1215 | - } |
|
| 1216 | - } |
|
| 1217 | - if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1218 | - if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1219 | - $prepend_code['taches_generales_cron'] = ''; |
|
| 1220 | - } |
|
| 1221 | - foreach ($info['genie'] as $genie) { |
|
| 1222 | - $nom = $prefix . $genie['nom']; |
|
| 1223 | - $periode = max(60, intval($genie['periode'])); |
|
| 1224 | - if (charger_fonction($nom, 'genie', true)) { |
|
| 1225 | - $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1226 | - } else { |
|
| 1227 | - spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1228 | - } |
|
| 1229 | - } |
|
| 1230 | - } |
|
| 1231 | - if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1232 | - if (!isset($prepend_code['insert_head_css'])) { |
|
| 1233 | - $prepend_code['insert_head_css'] = ''; |
|
| 1234 | - } |
|
| 1235 | - if (!isset($prepend_code['header_prive_css'])) { |
|
| 1236 | - $prepend_code['header_prive_css'] = ''; |
|
| 1237 | - } |
|
| 1238 | - foreach ($info['style'] as $style) { |
|
| 1239 | - if (isset($style['path']) and $style['path']) { |
|
| 1240 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1241 | - } else { |
|
| 1242 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1243 | - } |
|
| 1244 | - $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1245 | - if (isset($style['media']) and strlen($style['media'])) { |
|
| 1246 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1247 | - } |
|
| 1248 | - $code .= "/>';\n"; |
|
| 1249 | - if ($style['type'] != 'prive') { |
|
| 1250 | - $prepend_code['insert_head_css'] .= $code; |
|
| 1251 | - } |
|
| 1252 | - if ($style['type'] != 'public') { |
|
| 1253 | - $prepend_code['header_prive_css'] .= $code; |
|
| 1254 | - } |
|
| 1255 | - } |
|
| 1256 | - } |
|
| 1257 | - if (!isset($prepend_code['insert_head'])) { |
|
| 1258 | - $prepend_code['insert_head'] = ''; |
|
| 1259 | - } |
|
| 1260 | - if (!isset($prepend_code['header_prive'])) { |
|
| 1261 | - $prepend_code['header_prive'] = ''; |
|
| 1262 | - } |
|
| 1263 | - if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1264 | - foreach ($info['script'] as $script) { |
|
| 1265 | - if (isset($script['path']) and $script['path']) { |
|
| 1266 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1267 | - } else { |
|
| 1268 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1269 | - } |
|
| 1270 | - $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1271 | - if ($script['type'] != 'prive') { |
|
| 1272 | - $prepend_code['insert_head'] .= $code; |
|
| 1273 | - } |
|
| 1274 | - if ($script['type'] != 'public') { |
|
| 1275 | - $prepend_code['header_prive'] .= $code; |
|
| 1276 | - } |
|
| 1277 | - } |
|
| 1278 | - } |
|
| 1279 | - } |
|
| 1280 | - } |
|
| 1281 | - |
|
| 1282 | - $prepend_code['insert_head'] = |
|
| 1283 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1284 | - . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1285 | - . $prepend_code['insert_head']; |
|
| 1286 | - $prepend_code['header_prive'] = |
|
| 1287 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1288 | - . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1289 | - . $prepend_code['header_prive']; |
|
| 1290 | - |
|
| 1291 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 1292 | - foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1293 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1294 | - $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1295 | - } |
|
| 1296 | - } |
|
| 1297 | - |
|
| 1298 | - return $prepend_code; |
|
| 1165 | + static $liste_pipe_manquants = []; |
|
| 1166 | + if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1167 | + $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + $prepend_code = []; |
|
| 1171 | + |
|
| 1172 | + foreach ($ordre as $p => $info) { |
|
| 1173 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1174 | + if (isset($plugin_valides[$p])) { |
|
| 1175 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1176 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1177 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1178 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1179 | + if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1180 | + foreach ($info['pipeline'] as $pipe) { |
|
| 1181 | + $nom = $pipe['nom']; |
|
| 1182 | + if (isset($pipe['action'])) { |
|
| 1183 | + $action = $pipe['action']; |
|
| 1184 | + } else { |
|
| 1185 | + $action = $nom; |
|
| 1186 | + } |
|
| 1187 | + $nomlower = strtolower($nom); |
|
| 1188 | + if ( |
|
| 1189 | + $nomlower != $nom |
|
| 1190 | + and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1191 | + and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1192 | + ) { |
|
| 1193 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1194 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1195 | + } |
|
| 1196 | + $nom = $nomlower; |
|
| 1197 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1198 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1199 | + $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1200 | + } |
|
| 1201 | + if ($action) { |
|
| 1202 | + if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1203 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1204 | + ',(\|\||$),', |
|
| 1205 | + "|$prefix$action\\1", |
|
| 1206 | + $GLOBALS['spip_pipeline'][$nom], |
|
| 1207 | + 1 |
|
| 1208 | + ); |
|
| 1209 | + } |
|
| 1210 | + if (isset($pipe['inclure'])) { |
|
| 1211 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1212 | + "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1213 | + } |
|
| 1214 | + } |
|
| 1215 | + } |
|
| 1216 | + } |
|
| 1217 | + if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1218 | + if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1219 | + $prepend_code['taches_generales_cron'] = ''; |
|
| 1220 | + } |
|
| 1221 | + foreach ($info['genie'] as $genie) { |
|
| 1222 | + $nom = $prefix . $genie['nom']; |
|
| 1223 | + $periode = max(60, intval($genie['periode'])); |
|
| 1224 | + if (charger_fonction($nom, 'genie', true)) { |
|
| 1225 | + $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1226 | + } else { |
|
| 1227 | + spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1228 | + } |
|
| 1229 | + } |
|
| 1230 | + } |
|
| 1231 | + if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1232 | + if (!isset($prepend_code['insert_head_css'])) { |
|
| 1233 | + $prepend_code['insert_head_css'] = ''; |
|
| 1234 | + } |
|
| 1235 | + if (!isset($prepend_code['header_prive_css'])) { |
|
| 1236 | + $prepend_code['header_prive_css'] = ''; |
|
| 1237 | + } |
|
| 1238 | + foreach ($info['style'] as $style) { |
|
| 1239 | + if (isset($style['path']) and $style['path']) { |
|
| 1240 | + $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1241 | + } else { |
|
| 1242 | + $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1243 | + } |
|
| 1244 | + $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1245 | + if (isset($style['media']) and strlen($style['media'])) { |
|
| 1246 | + $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1247 | + } |
|
| 1248 | + $code .= "/>';\n"; |
|
| 1249 | + if ($style['type'] != 'prive') { |
|
| 1250 | + $prepend_code['insert_head_css'] .= $code; |
|
| 1251 | + } |
|
| 1252 | + if ($style['type'] != 'public') { |
|
| 1253 | + $prepend_code['header_prive_css'] .= $code; |
|
| 1254 | + } |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1257 | + if (!isset($prepend_code['insert_head'])) { |
|
| 1258 | + $prepend_code['insert_head'] = ''; |
|
| 1259 | + } |
|
| 1260 | + if (!isset($prepend_code['header_prive'])) { |
|
| 1261 | + $prepend_code['header_prive'] = ''; |
|
| 1262 | + } |
|
| 1263 | + if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1264 | + foreach ($info['script'] as $script) { |
|
| 1265 | + if (isset($script['path']) and $script['path']) { |
|
| 1266 | + $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1267 | + } else { |
|
| 1268 | + $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1269 | + } |
|
| 1270 | + $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1271 | + if ($script['type'] != 'prive') { |
|
| 1272 | + $prepend_code['insert_head'] .= $code; |
|
| 1273 | + } |
|
| 1274 | + if ($script['type'] != 'public') { |
|
| 1275 | + $prepend_code['header_prive'] .= $code; |
|
| 1276 | + } |
|
| 1277 | + } |
|
| 1278 | + } |
|
| 1279 | + } |
|
| 1280 | + } |
|
| 1281 | + |
|
| 1282 | + $prepend_code['insert_head'] = |
|
| 1283 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1284 | + . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1285 | + . $prepend_code['insert_head']; |
|
| 1286 | + $prepend_code['header_prive'] = |
|
| 1287 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1288 | + . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1289 | + . $prepend_code['header_prive']; |
|
| 1290 | + |
|
| 1291 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 1292 | + foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1293 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1294 | + $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1295 | + } |
|
| 1296 | + } |
|
| 1297 | + |
|
| 1298 | + return $prepend_code; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1322,62 +1322,62 @@ discard block |
||
| 1322 | 1322 | **/ |
| 1323 | 1323 | function pipeline_precompile($prepend_code = []) { |
| 1324 | 1324 | |
| 1325 | - $all_pipes = $all_pipes_end = ''; |
|
| 1326 | - if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1327 | - $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1328 | - unset($GLOBALS['spip_pipeline']['all']); |
|
| 1329 | - $all_pipes = trim(array_shift($a)); |
|
| 1330 | - if ($all_pipes) { |
|
| 1331 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1332 | - } |
|
| 1333 | - if (count($a)) { |
|
| 1334 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1335 | - } |
|
| 1336 | - } |
|
| 1337 | - $content = ''; |
|
| 1338 | - foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1339 | - $s_inc = ''; |
|
| 1340 | - $s_call = ''; |
|
| 1341 | - if ($all_pipes) { |
|
| 1342 | - $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1343 | - } |
|
| 1344 | - if ($all_pipes_end) { |
|
| 1345 | - $pipeline .= $all_pipes_end; |
|
| 1346 | - } |
|
| 1347 | - $pipe = array_filter(explode('|', $pipeline)); |
|
| 1348 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1349 | - foreach ($pipe as $fonc) { |
|
| 1350 | - $fonc = trim($fonc); |
|
| 1351 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1352 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1353 | - $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1354 | - $file = "'$file'"; |
|
| 1355 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1356 | - if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1357 | - $dir = $regs[1]; |
|
| 1358 | - $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1359 | - if (defined($root_dir)) { |
|
| 1360 | - $dir = $root_dir; |
|
| 1361 | - } |
|
| 1362 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1363 | - $file = str_replace("''.", '', $file); |
|
| 1364 | - $file = str_replace(constant($dir), '', $file); |
|
| 1365 | - } |
|
| 1366 | - $s_inc .= "include_once_check($file);\n"; |
|
| 1367 | - } |
|
| 1368 | - } |
|
| 1369 | - if (strlen($s_inc)) { |
|
| 1370 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1371 | - } |
|
| 1372 | - $content .= "// Pipeline $action \n" |
|
| 1373 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 1374 | - . $s_inc |
|
| 1375 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1376 | - . $s_call |
|
| 1377 | - . "return \$val;\n}\n"; |
|
| 1378 | - } |
|
| 1379 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1380 | - clear_path_cache(); |
|
| 1325 | + $all_pipes = $all_pipes_end = ''; |
|
| 1326 | + if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1327 | + $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1328 | + unset($GLOBALS['spip_pipeline']['all']); |
|
| 1329 | + $all_pipes = trim(array_shift($a)); |
|
| 1330 | + if ($all_pipes) { |
|
| 1331 | + $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1332 | + } |
|
| 1333 | + if (count($a)) { |
|
| 1334 | + $all_pipes_end = '||' . array_shift($a); |
|
| 1335 | + } |
|
| 1336 | + } |
|
| 1337 | + $content = ''; |
|
| 1338 | + foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1339 | + $s_inc = ''; |
|
| 1340 | + $s_call = ''; |
|
| 1341 | + if ($all_pipes) { |
|
| 1342 | + $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1343 | + } |
|
| 1344 | + if ($all_pipes_end) { |
|
| 1345 | + $pipeline .= $all_pipes_end; |
|
| 1346 | + } |
|
| 1347 | + $pipe = array_filter(explode('|', $pipeline)); |
|
| 1348 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1349 | + foreach ($pipe as $fonc) { |
|
| 1350 | + $fonc = trim($fonc); |
|
| 1351 | + $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1352 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1353 | + $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1354 | + $file = "'$file'"; |
|
| 1355 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1356 | + if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1357 | + $dir = $regs[1]; |
|
| 1358 | + $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1359 | + if (defined($root_dir)) { |
|
| 1360 | + $dir = $root_dir; |
|
| 1361 | + } |
|
| 1362 | + $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1363 | + $file = str_replace("''.", '', $file); |
|
| 1364 | + $file = str_replace(constant($dir), '', $file); |
|
| 1365 | + } |
|
| 1366 | + $s_inc .= "include_once_check($file);\n"; |
|
| 1367 | + } |
|
| 1368 | + } |
|
| 1369 | + if (strlen($s_inc)) { |
|
| 1370 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1371 | + } |
|
| 1372 | + $content .= "// Pipeline $action \n" |
|
| 1373 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 1374 | + . $s_inc |
|
| 1375 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1376 | + . $s_call |
|
| 1377 | + . "return \$val;\n}\n"; |
|
| 1378 | + } |
|
| 1379 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1380 | + clear_path_cache(); |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | |
@@ -1390,12 +1390,12 @@ discard block |
||
| 1390 | 1390 | * true si le plugin est actif, false sinon |
| 1391 | 1391 | **/ |
| 1392 | 1392 | function plugin_est_installe($plug_path) { |
| 1393 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1394 | - if (!$plugin_installes) { |
|
| 1395 | - return false; |
|
| 1396 | - } |
|
| 1393 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1394 | + if (!$plugin_installes) { |
|
| 1395 | + return false; |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | - return in_array($plug_path, $plugin_installes); |
|
| 1398 | + return in_array($plug_path, $plugin_installes); |
|
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | |
@@ -1408,46 +1408,46 @@ discard block |
||
| 1408 | 1408 | * @uses plugins_installer_dist() |
| 1409 | 1409 | **/ |
| 1410 | 1410 | function plugin_installes_meta() { |
| 1411 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1412 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 1413 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1417 | - $meta_plug_installes = []; |
|
| 1418 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1419 | - if ($plug = $resume['dir']) { |
|
| 1420 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1421 | - if ($infos) { |
|
| 1422 | - if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1423 | - $meta_plug_installes[] = $plug; |
|
| 1424 | - } |
|
| 1425 | - if (is_array($infos)) { |
|
| 1426 | - [$ok, $trace] = $infos['install_test']; |
|
| 1427 | - $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1428 | - $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1429 | - if (_IS_CLI) { |
|
| 1430 | - include_spip('inc/filtres'); |
|
| 1431 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1434 | - $trace, |
|
| 1435 | - "\n"; |
|
| 1436 | - } |
|
| 1437 | - else { |
|
| 1438 | - include_spip('inc/filtres_boites'); |
|
| 1439 | - echo "<div class='install-plugins svp_retour'>" |
|
| 1440 | - . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1441 | - . $trace |
|
| 1442 | - . "<div class='result'>$result</div>" |
|
| 1443 | - . boite_fermer() |
|
| 1444 | - . '</div>'; |
|
| 1445 | - } |
|
| 1446 | - } |
|
| 1447 | - } |
|
| 1448 | - } |
|
| 1449 | - } |
|
| 1450 | - ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1411 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1412 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 1413 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1414 | + } |
|
| 1415 | + |
|
| 1416 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1417 | + $meta_plug_installes = []; |
|
| 1418 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1419 | + if ($plug = $resume['dir']) { |
|
| 1420 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1421 | + if ($infos) { |
|
| 1422 | + if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1423 | + $meta_plug_installes[] = $plug; |
|
| 1424 | + } |
|
| 1425 | + if (is_array($infos)) { |
|
| 1426 | + [$ok, $trace] = $infos['install_test']; |
|
| 1427 | + $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1428 | + $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1429 | + if (_IS_CLI) { |
|
| 1430 | + include_spip('inc/filtres'); |
|
| 1431 | + $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | + $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | + echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1434 | + $trace, |
|
| 1435 | + "\n"; |
|
| 1436 | + } |
|
| 1437 | + else { |
|
| 1438 | + include_spip('inc/filtres_boites'); |
|
| 1439 | + echo "<div class='install-plugins svp_retour'>" |
|
| 1440 | + . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1441 | + . $trace |
|
| 1442 | + . "<div class='result'>$result</div>" |
|
| 1443 | + . boite_fermer() |
|
| 1444 | + . '</div>'; |
|
| 1445 | + } |
|
| 1446 | + } |
|
| 1447 | + } |
|
| 1448 | + } |
|
| 1449 | + } |
|
| 1450 | + ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | /** |
@@ -1461,29 +1461,29 @@ discard block |
||
| 1461 | 1461 | * Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante |
| 1462 | 1462 | **/ |
| 1463 | 1463 | function ecrire_fichier_php($nom, $contenu, $comment = '') { |
| 1464 | - if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1465 | - $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1466 | - } |
|
| 1467 | - |
|
| 1468 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1469 | - // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1470 | - // si pas de modif on ne touche pas au fichier initial |
|
| 1471 | - if (file_exists($nom)) { |
|
| 1472 | - if (substr($nom, -4) == '.php') { |
|
| 1473 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1474 | - } |
|
| 1475 | - else { |
|
| 1476 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1477 | - } |
|
| 1478 | - file_put_contents($fichier_tmp, $contenu); |
|
| 1479 | - if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1480 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1481 | - @unlink($fichier_tmp); |
|
| 1482 | - return; |
|
| 1483 | - } |
|
| 1484 | - @unlink($fichier_tmp); |
|
| 1485 | - } |
|
| 1486 | - ecrire_fichier($nom, $contenu); |
|
| 1487 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1488 | - spip_clear_opcode_cache(realpath($nom)); |
|
| 1464 | + if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1465 | + $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1469 | + // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1470 | + // si pas de modif on ne touche pas au fichier initial |
|
| 1471 | + if (file_exists($nom)) { |
|
| 1472 | + if (substr($nom, -4) == '.php') { |
|
| 1473 | + $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1474 | + } |
|
| 1475 | + else { |
|
| 1476 | + $fichier_tmp = $nom . '.tmp'; |
|
| 1477 | + } |
|
| 1478 | + file_put_contents($fichier_tmp, $contenu); |
|
| 1479 | + if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1480 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1481 | + @unlink($fichier_tmp); |
|
| 1482 | + return; |
|
| 1483 | + } |
|
| 1484 | + @unlink($fichier_tmp); |
|
| 1485 | + } |
|
| 1486 | + ecrire_fichier($nom, $contenu); |
|
| 1487 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1488 | + spip_clear_opcode_cache(realpath($nom)); |
|
| 1489 | 1489 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | if ($dir) { |
| 382 | 382 | $dir .= '/'; |
| 383 | 383 | } |
| 384 | - $dir .= 'procure:' . $procure['nom']; |
|
| 384 | + $dir .= 'procure:'.$procure['nom']; |
|
| 385 | 385 | |
| 386 | 386 | $procure['etat'] = '?'; |
| 387 | 387 | $procure['dir_type'] = $resume['dir_type']; |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | $plug = $resume['dir']; |
| 566 | 566 | $k = $infos[$dir_type][$plug]; |
| 567 | 567 | |
| 568 | - $plug = constant($dir_type) . $plug; |
|
| 568 | + $plug = constant($dir_type).$plug; |
|
| 569 | 569 | if (!isset($msg[$p])) { |
| 570 | 570 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 571 | 571 | $msg[$p] = [$resume['erreur']]; |
@@ -608,10 +608,10 @@ discard block |
||
| 608 | 608 | $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
| 609 | 609 | } elseif (!$raw) { |
| 610 | 610 | foreach ($list as $plug => $msg) { |
| 611 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 611 | + $list[$plug] = '<li>'._T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | + . '<ul><li>'.implode('</li><li>', $msg).'</li></ul></li>'; |
|
| 613 | 613 | } |
| 614 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 614 | + $list = '<ul>'.join("\n", $list).'</ul>'; |
|
| 615 | 615 | } |
| 616 | 616 | if ($raz) { |
| 617 | 617 | effacer_meta('plugin_erreur_activation'); |
@@ -725,13 +725,13 @@ discard block |
||
| 725 | 725 | if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
| 726 | 726 | return _T("plugin_{$balise}_{$type}", [ |
| 727 | 727 | 'plugin' => $nom, |
| 728 | - 'version' => ' ≥ ' . $minimum |
|
| 728 | + 'version' => ' ≥ '.$minimum |
|
| 729 | 729 | ]); |
| 730 | 730 | } |
| 731 | 731 | if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
| 732 | 732 | return _T("plugin_{$balise}_{$type}", [ |
| 733 | 733 | 'plugin' => $nom, |
| 734 | - 'version' => ' > ' . $minimum |
|
| 734 | + 'version' => ' > '.$minimum |
|
| 735 | 735 | ]); |
| 736 | 736 | } |
| 737 | 737 | } |
@@ -740,13 +740,13 @@ discard block |
||
| 740 | 740 | if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
| 741 | 741 | return _T("plugin_{$balise}_{$type}", [ |
| 742 | 742 | 'plugin' => $nom, |
| 743 | - 'version' => ' ≤ ' . $maximum |
|
| 743 | + 'version' => ' ≤ '.$maximum |
|
| 744 | 744 | ]); |
| 745 | 745 | } |
| 746 | 746 | if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
| 747 | 747 | return _T("plugin_{$balise}_plugin", [ |
| 748 | 748 | 'plugin' => $nom, |
| 749 | - 'version' => ' < ' . $maximum |
|
| 749 | + 'version' => ' < '.$maximum |
|
| 750 | 750 | ]); |
| 751 | 751 | } |
| 752 | 752 | } |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | include_spip('inc/charger_plugin'); |
| 766 | 766 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 767 | 767 | }*/ |
| 768 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 768 | + return _T('plugin_necessite_lib', ['lib' => $lib])." <a href='$url'>$url</a>"; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | foreach ($plugin_valides as $p => $resume) { |
| 866 | 866 | // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
| 867 | 867 | if (!str_starts_with($p, 'PHP:') and $p !== 'PHP') { |
| 868 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 868 | + $header[] = $p.($resume['version'] ? '('.$resume['version'].')' : ''); |
|
| 869 | 869 | } |
| 870 | 870 | if ($resume['dir']) { |
| 871 | 871 | foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
@@ -890,11 +890,11 @@ discard block |
||
| 890 | 890 | $header = strtolower(implode(',', $header)); |
| 891 | 891 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 892 | 892 | ecrire_fichier( |
| 893 | - _DIR_VAR . 'config.txt', |
|
| 894 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 893 | + _DIR_VAR.'config.txt', |
|
| 894 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP').' '.$GLOBALS['spip_version_affichee'].' @ www.spip.net + '.$header |
|
| 895 | 895 | ); |
| 896 | 896 | } else { |
| 897 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 897 | + @unlink(_DIR_VAR.'config.txt'); |
|
| 898 | 898 | } |
| 899 | 899 | // generer charger_plugins_chemin.php |
| 900 | 900 | plugins_precompile_chemin($plugin_valides, $ordre); |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | // definir le plugin, donc le path avant l'include du fichier options |
| 949 | 949 | // permet de faire des include_spip pour attraper un inc_ du plugin |
| 950 | 950 | |
| 951 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 951 | + $dir = $dir_type.".'".$plug."/'"; |
|
| 952 | 952 | |
| 953 | 953 | $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
| 954 | 954 | if ( |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | if (!$info['chemin']) { |
| 960 | 960 | $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
| 961 | 961 | $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
| 962 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 962 | + if (is_dir(constant($dir_type).$plug.'/squelettes/')) { |
|
| 963 | 963 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 964 | 964 | } |
| 965 | 965 | } |
@@ -980,13 +980,13 @@ discard block |
||
| 980 | 980 | $dir = ''; |
| 981 | 981 | } |
| 982 | 982 | if (strlen($dir)) { |
| 983 | - $dir = rtrim($dir, '/') . '/'; |
|
| 983 | + $dir = rtrim($dir, '/').'/'; |
|
| 984 | 984 | } |
| 985 | 985 | if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
| 986 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 986 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | 987 | } |
| 988 | 988 | if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
| 989 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 989 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | } |
@@ -995,11 +995,11 @@ discard block |
||
| 995 | 995 | } |
| 996 | 996 | } |
| 997 | 997 | if (count($chemins['public']) or count($chemins['prive'])) { |
| 998 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 998 | + $contenu .= 'if (_DIR_RESTREINT) _chemin(['.implode( |
|
| 999 | 999 | ',', |
| 1000 | 1000 | array_reverse($chemins['public']) |
| 1001 | - ) . "]);\n" |
|
| 1002 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1001 | + )."]);\n" |
|
| 1002 | + . 'else _chemin(['.implode(',', array_reverse($chemins['prive']))."]);\n"; |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | and !str_contains($dir, ':') // exclure le cas des procure: |
| 1049 | 1049 | and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
| 1050 | 1050 | ) { |
| 1051 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1051 | + if (is_readable("$dir$plug/".($file = $info['prefix'].'_'.$charge.'.php'))) { |
|
| 1052 | 1052 | $info[$charge] = [$file]; |
| 1053 | 1053 | } |
| 1054 | 1054 | } |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | ) { |
| 1066 | 1066 | unset($info[$charge][$k]); |
| 1067 | 1067 | } else { |
| 1068 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1068 | + $_file = $root_dir_type.".'$plug/$file'"; |
|
| 1069 | 1069 | $contenu[$charge] .= "include_once_check($_file);\n"; |
| 1070 | 1070 | } |
| 1071 | 1071 | } |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | } |
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1078 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options']; |
|
| 1079 | 1079 | $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
| 1080 | 1080 | . plugin_ongletbouton('onglets_plugins', $onglets); |
| 1081 | 1081 | |
@@ -1110,12 +1110,12 @@ discard block |
||
| 1110 | 1110 | define("_UPDATED_$nom", $val); |
| 1111 | 1111 | define("_UPDATED_md5_$nom", $md5); |
| 1112 | 1112 | } |
| 1113 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1113 | + $val = "unserialize('".str_replace("'", "\'", $val)."')"; |
|
| 1114 | 1114 | |
| 1115 | 1115 | return |
| 1116 | 1116 | "if (!function_exists('$nom')) {\n" |
| 1117 | 1117 | . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
| 1118 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1118 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 1119 | 1119 | . "}\n"; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
@@ -1138,7 +1138,7 @@ discard block |
||
| 1138 | 1138 | if (@is_readable(_CACHE_PLUGINS_OPT)) { |
| 1139 | 1139 | include_once(_CACHE_PLUGINS_OPT); |
| 1140 | 1140 | } else { |
| 1141 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1141 | + spip_log('pipelines desactives: impossible de produire '._CACHE_PLUGINS_OPT); |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | $dir_type = $plugin_valides[$p]['dir_type']; |
| 1176 | 1176 | $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
| 1177 | 1177 | $plug = $plugin_valides[$p]['dir']; |
| 1178 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1178 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'].'_'); |
|
| 1179 | 1179 | if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
| 1180 | 1180 | foreach ($info['pipeline'] as $pipe) { |
| 1181 | 1181 | $nom = $pipe['nom']; |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | } |
| 1210 | 1210 | if (isset($pipe['inclure'])) { |
| 1211 | 1211 | $GLOBALS['spip_matrice']["$prefix$action"] = |
| 1212 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1212 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | 1215 | } |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | $prepend_code['taches_generales_cron'] = ''; |
| 1220 | 1220 | } |
| 1221 | 1221 | foreach ($info['genie'] as $genie) { |
| 1222 | - $nom = $prefix . $genie['nom']; |
|
| 1222 | + $nom = $prefix.$genie['nom']; |
|
| 1223 | 1223 | $periode = max(60, intval($genie['periode'])); |
| 1224 | 1224 | if (charger_fonction($nom, 'genie', true)) { |
| 1225 | 1225 | $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
@@ -1237,13 +1237,13 @@ discard block |
||
| 1237 | 1237 | } |
| 1238 | 1238 | foreach ($info['style'] as $style) { |
| 1239 | 1239 | if (isset($style['path']) and $style['path']) { |
| 1240 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1240 | + $code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) "; |
|
| 1241 | 1241 | } else { |
| 1242 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1242 | + $code = "if (\$f='".addslashes($style['url'])."') "; |
|
| 1243 | 1243 | } |
| 1244 | 1244 | $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
| 1245 | 1245 | if (isset($style['media']) and strlen($style['media'])) { |
| 1246 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1246 | + $code .= ' media="'.addslashes($style['media']).'"'; |
|
| 1247 | 1247 | } |
| 1248 | 1248 | $code .= "/>';\n"; |
| 1249 | 1249 | if ($style['type'] != 'prive') { |
@@ -1263,9 +1263,9 @@ discard block |
||
| 1263 | 1263 | if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
| 1264 | 1264 | foreach ($info['script'] as $script) { |
| 1265 | 1265 | if (isset($script['path']) and $script['path']) { |
| 1266 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1266 | + $code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) "; |
|
| 1267 | 1267 | } else { |
| 1268 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1268 | + $code = "if (\$f='".addslashes($script['url'])."') "; |
|
| 1269 | 1269 | } |
| 1270 | 1270 | $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
| 1271 | 1271 | if ($script['type'] != 'prive') { |
@@ -1328,10 +1328,10 @@ discard block |
||
| 1328 | 1328 | unset($GLOBALS['spip_pipeline']['all']); |
| 1329 | 1329 | $all_pipes = trim(array_shift($a)); |
| 1330 | 1330 | if ($all_pipes) { |
| 1331 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1331 | + $all_pipes = '|'.ltrim($all_pipes, '|'); |
|
| 1332 | 1332 | } |
| 1333 | 1333 | if (count($a)) { |
| 1334 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1334 | + $all_pipes_end = '||'.array_shift($a); |
|
| 1335 | 1335 | } |
| 1336 | 1336 | } |
| 1337 | 1337 | $content = ''; |
@@ -1348,7 +1348,7 @@ discard block |
||
| 1348 | 1348 | // Eclater le pipeline en filtres et appliquer chaque filtre |
| 1349 | 1349 | foreach ($pipe as $fonc) { |
| 1350 | 1350 | $fonc = trim($fonc); |
| 1351 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1351 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 1352 | 1352 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 1353 | 1353 | $file = $GLOBALS['spip_matrice'][$fonc]; |
| 1354 | 1354 | $file = "'$file'"; |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | if (defined($root_dir)) { |
| 1360 | 1360 | $dir = $root_dir; |
| 1361 | 1361 | } |
| 1362 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1362 | + $file = str_replace($regs[0], "'.".$dir.".'", $file); |
|
| 1363 | 1363 | $file = str_replace("''.", '', $file); |
| 1364 | 1364 | $file = str_replace(constant($dir), '', $file); |
| 1365 | 1365 | } |
@@ -1372,7 +1372,7 @@ discard block |
||
| 1372 | 1372 | $content .= "// Pipeline $action \n" |
| 1373 | 1373 | . "function execute_pipeline_$action(&\$val){\n" |
| 1374 | 1374 | . $s_inc |
| 1375 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1375 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '') |
|
| 1376 | 1376 | . $s_call |
| 1377 | 1377 | . "return \$val;\n}\n"; |
| 1378 | 1378 | } |
@@ -1428,9 +1428,9 @@ discard block |
||
| 1428 | 1428 | $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
| 1429 | 1429 | if (_IS_CLI) { |
| 1430 | 1430 | include_spip('inc/filtres'); |
| 1431 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1431 | + $trace = ltrim(textebrut($trace)."\n".$result); |
|
| 1432 | + $trace = ' '.str_replace("\n", "\n ", $trace); |
|
| 1433 | + echo "\n".($ok ? 'OK ' : '/!\ ').textebrut($titre)."\n", |
|
| 1434 | 1434 | $trace, |
| 1435 | 1435 | "\n"; |
| 1436 | 1436 | } |
@@ -1465,15 +1465,15 @@ discard block |
||
| 1465 | 1465 | $GLOBALS['fichier_php_compile_recent'] = 0; |
| 1466 | 1466 | } |
| 1467 | 1467 | |
| 1468 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1468 | + $contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>'; |
|
| 1469 | 1469 | // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
| 1470 | 1470 | // si pas de modif on ne touche pas au fichier initial |
| 1471 | 1471 | if (file_exists($nom)) { |
| 1472 | 1472 | if (substr($nom, -4) == '.php') { |
| 1473 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1473 | + $fichier_tmp = substr($nom, 0, -4).'.tmp.php'; |
|
| 1474 | 1474 | } |
| 1475 | 1475 | else { |
| 1476 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1476 | + $fichier_tmp = $nom.'.tmp'; |
|
| 1477 | 1477 | } |
| 1478 | 1478 | file_put_contents($fichier_tmp, $contenu); |
| 1479 | 1479 | if (md5_file($nom) == md5_file($fichier_tmp)) { |
@@ -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 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -40,29 +40,29 @@ discard block |
||
| 40 | 40 | * Code HTML de la liste |
| 41 | 41 | */ |
| 42 | 42 | function inc_lister_objets_dist($vue, $contexte = [], $force = false) { |
| 43 | - $res = ''; // debug |
|
| 44 | - if (!is_array($contexte)) { |
|
| 45 | - return _L('$contexte doit etre un tableau dans inc/lister_objets'); |
|
| 46 | - } |
|
| 43 | + $res = ''; // debug |
|
| 44 | + if (!is_array($contexte)) { |
|
| 45 | + return _L('$contexte doit etre un tableau dans inc/lister_objets'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $fond = "prive/objets/liste/$vue"; |
|
| 49 | - if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) { |
|
| 50 | - // traiter les cas particuliers |
|
| 51 | - include_spip('base/connect_sql'); |
|
| 52 | - $vue = table_objet($vue); |
|
| 53 | - $fond = "prive/objets/liste/$vue"; |
|
| 54 | - if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) { |
|
| 55 | - return _L("vue $vue introuvable pour lister les objets"); |
|
| 56 | - } |
|
| 57 | - } |
|
| 48 | + $fond = "prive/objets/liste/$vue"; |
|
| 49 | + if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) { |
|
| 50 | + // traiter les cas particuliers |
|
| 51 | + include_spip('base/connect_sql'); |
|
| 52 | + $vue = table_objet($vue); |
|
| 53 | + $fond = "prive/objets/liste/$vue"; |
|
| 54 | + if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) { |
|
| 55 | + return _L("vue $vue introuvable pour lister les objets"); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - $contexte['sinon'] = ($force ? $contexte['titre'] : ''); |
|
| 60 | + $contexte['sinon'] = ($force ? $contexte['titre'] : ''); |
|
| 61 | 61 | |
| 62 | - $res = recuperer_fond($fond, $contexte, ['ajax' => true]); |
|
| 63 | - if (_request('var_liste')) { |
|
| 64 | - echo var_export($contexte, true); |
|
| 65 | - } |
|
| 62 | + $res = recuperer_fond($fond, $contexte, ['ajax' => true]); |
|
| 63 | + if (_request('var_liste')) { |
|
| 64 | + echo var_export($contexte, true); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return $res; |
|
| 67 | + return $res; |
|
| 68 | 68 | } |
@@ -46,12 +46,12 @@ |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $fond = "prive/objets/liste/$vue"; |
| 49 | - if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) { |
|
| 49 | + if (!find_in_path($fond.'.'._EXTENSION_SQUELETTES)) { |
|
| 50 | 50 | // traiter les cas particuliers |
| 51 | 51 | include_spip('base/connect_sql'); |
| 52 | 52 | $vue = table_objet($vue); |
| 53 | 53 | $fond = "prive/objets/liste/$vue"; |
| 54 | - if (!find_in_path($fond . '.' . _EXTENSION_SQUELETTES)) { |
|
| 54 | + if (!find_in_path($fond.'.'._EXTENSION_SQUELETTES)) { |
|
| 55 | 55 | return _L("vue $vue introuvable pour lister les objets"); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -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) and file_exists($script)) |
|
| 54 | - or $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 | - and $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) and file_exists($script)) |
|
| 54 | + or $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 | + and $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,42 +80,42 @@ discard block |
||
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | 82 | function affichage_final_prive_title_auto($texte) { |
| 83 | - if ( |
|
| 84 | - strpos($texte, '<title>') === false |
|
| 85 | - and |
|
| 86 | - (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) |
|
| 87 | - or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 88 | - and $match = textebrut(trim($match[1])) |
|
| 89 | - and ($p = strpos($texte, '<head>')) !== false |
|
| 90 | - ) { |
|
| 91 | - if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 92 | - $nom_site_spip = _T('info_mon_site_spip'); |
|
| 93 | - } |
|
| 83 | + if ( |
|
| 84 | + strpos($texte, '<title>') === false |
|
| 85 | + and |
|
| 86 | + (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) |
|
| 87 | + or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 88 | + and $match = textebrut(trim($match[1])) |
|
| 89 | + and ($p = strpos($texte, '<head>')) !== false |
|
| 90 | + ) { |
|
| 91 | + if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 92 | + $nom_site_spip = _T('info_mon_site_spip'); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - $titre = '<title>[' |
|
| 96 | - . $nom_site_spip |
|
| 97 | - . '] ' . $match |
|
| 98 | - . '</title>'; |
|
| 95 | + $titre = '<title>[' |
|
| 96 | + . $nom_site_spip |
|
| 97 | + . '] ' . $match |
|
| 98 | + . '</title>'; |
|
| 99 | 99 | |
| 100 | - $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 101 | - } |
|
| 100 | + $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - return $texte; |
|
| 103 | + return $texte; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | // Fonction standard pour le pipeline 'boite_infos' |
| 108 | 108 | function f_boite_infos($flux) { |
| 109 | - $args = $flux['args']; |
|
| 110 | - $type = $args['type']; |
|
| 111 | - unset($args['row']); |
|
| 112 | - if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 113 | - $type = 'objet'; |
|
| 114 | - } |
|
| 115 | - $args['espace_prive'] = 1; |
|
| 116 | - $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 109 | + $args = $flux['args']; |
|
| 110 | + $type = $args['type']; |
|
| 111 | + unset($args['row']); |
|
| 112 | + if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 113 | + $type = 'objet'; |
|
| 114 | + } |
|
| 115 | + $args['espace_prive'] = 1; |
|
| 116 | + $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 117 | 117 | |
| 118 | - return $flux; |
|
| 118 | + return $flux; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -134,97 +134,97 @@ discard block |
||
| 134 | 134 | * @return array Données du pipeline |
| 135 | 135 | */ |
| 136 | 136 | function f_afficher_blocs_ecrire($flux) { |
| 137 | - static $o = []; |
|
| 138 | - if (is_string($fond = $flux['args']['fond'])) { |
|
| 139 | - $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 140 | - if (!isset($o[$exec])) { |
|
| 141 | - $o[$exec] = trouver_objet_exec($exec); |
|
| 142 | - } |
|
| 143 | - // cas particulier |
|
| 144 | - if ($exec == 'infos_perso') { |
|
| 145 | - $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 146 | - } |
|
| 147 | - $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 148 | - if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 149 | - $flux['data']['texte'] = pipeline( |
|
| 150 | - 'affiche_gauche', |
|
| 151 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 152 | - ); |
|
| 153 | - } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 154 | - include_spip('inc/presentation_mini'); |
|
| 155 | - $flux['data']['texte'] = pipeline( |
|
| 156 | - 'affiche_droite', |
|
| 157 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 158 | - ) . liste_objets_bloques( |
|
| 159 | - $exec, |
|
| 160 | - $flux['args']['contexte'] |
|
| 161 | - ); |
|
| 162 | - } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) { |
|
| 163 | - // id non defini sur les formulaire de nouveaux objets |
|
| 164 | - $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 165 | - $flux['data']['texte'] = pipeline( |
|
| 166 | - 'affiche_hierarchie', |
|
| 167 | - ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 168 | - ); |
|
| 169 | - } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 170 | - // Préparation du marqueur affiche_milieu |
|
| 171 | - // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 172 | - $est_page_objet = !empty($o[$exec]['type']); |
|
| 173 | - $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true); |
|
| 174 | - $encapsuler_milieu = ($est_page_objet and !$est_en_edition); |
|
| 175 | - $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 176 | - $flux['data']['texte'], |
|
| 177 | - '<!--affiche_milieu-->', |
|
| 178 | - '<div id=["\']wysiwyg', |
|
| 179 | - $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 180 | - $encapsuler_milieu ? '</div>' : '' |
|
| 181 | - ); |
|
| 182 | - if ( |
|
| 183 | - $o[$exec] |
|
| 184 | - and $objet = $o[$exec]['type'] |
|
| 185 | - and $o[$exec]['edition'] == false |
|
| 186 | - and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 187 | - and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 188 | - ) { |
|
| 189 | - // inserer le formulaire de traduction |
|
| 190 | - $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 191 | - 'prive/objets/editer/traductions', |
|
| 192 | - ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 193 | - ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 194 | - $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 195 | - 'args' => [ |
|
| 196 | - 'contexte' => $flux['args']['contexte'], |
|
| 197 | - 'type' => $objet, |
|
| 198 | - 'id' => $id |
|
| 199 | - ], |
|
| 200 | - 'data' => $flux['data']['texte'] |
|
| 201 | - ]); |
|
| 202 | - } |
|
| 203 | - $flux['data']['texte'] = pipeline( |
|
| 204 | - 'affiche_milieu', |
|
| 205 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 206 | - ); |
|
| 207 | - } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 208 | - $flux['data']['texte'] = pipeline( |
|
| 209 | - 'affiche_pied', |
|
| 210 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 211 | - ); |
|
| 212 | - } elseif ( |
|
| 213 | - strncmp($fond, 'prive/objets/contenu/', 21) == 0 |
|
| 214 | - and $objet = basename($fond) |
|
| 215 | - and $objet == substr($fond, 21) |
|
| 216 | - and isset($o[$objet]) |
|
| 217 | - and $o[$objet] |
|
| 218 | - ) { |
|
| 219 | - $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 220 | - $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 221 | - 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 222 | - 'data' => $flux['data']['texte'] |
|
| 223 | - ]); |
|
| 224 | - } |
|
| 225 | - } |
|
| 137 | + static $o = []; |
|
| 138 | + if (is_string($fond = $flux['args']['fond'])) { |
|
| 139 | + $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 140 | + if (!isset($o[$exec])) { |
|
| 141 | + $o[$exec] = trouver_objet_exec($exec); |
|
| 142 | + } |
|
| 143 | + // cas particulier |
|
| 144 | + if ($exec == 'infos_perso') { |
|
| 145 | + $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 146 | + } |
|
| 147 | + $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 148 | + if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 149 | + $flux['data']['texte'] = pipeline( |
|
| 150 | + 'affiche_gauche', |
|
| 151 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 152 | + ); |
|
| 153 | + } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 154 | + include_spip('inc/presentation_mini'); |
|
| 155 | + $flux['data']['texte'] = pipeline( |
|
| 156 | + 'affiche_droite', |
|
| 157 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 158 | + ) . liste_objets_bloques( |
|
| 159 | + $exec, |
|
| 160 | + $flux['args']['contexte'] |
|
| 161 | + ); |
|
| 162 | + } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) { |
|
| 163 | + // id non defini sur les formulaire de nouveaux objets |
|
| 164 | + $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 165 | + $flux['data']['texte'] = pipeline( |
|
| 166 | + 'affiche_hierarchie', |
|
| 167 | + ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 168 | + ); |
|
| 169 | + } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 170 | + // Préparation du marqueur affiche_milieu |
|
| 171 | + // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 172 | + $est_page_objet = !empty($o[$exec]['type']); |
|
| 173 | + $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true); |
|
| 174 | + $encapsuler_milieu = ($est_page_objet and !$est_en_edition); |
|
| 175 | + $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 176 | + $flux['data']['texte'], |
|
| 177 | + '<!--affiche_milieu-->', |
|
| 178 | + '<div id=["\']wysiwyg', |
|
| 179 | + $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 180 | + $encapsuler_milieu ? '</div>' : '' |
|
| 181 | + ); |
|
| 182 | + if ( |
|
| 183 | + $o[$exec] |
|
| 184 | + and $objet = $o[$exec]['type'] |
|
| 185 | + and $o[$exec]['edition'] == false |
|
| 186 | + and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 187 | + and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 188 | + ) { |
|
| 189 | + // inserer le formulaire de traduction |
|
| 190 | + $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 191 | + 'prive/objets/editer/traductions', |
|
| 192 | + ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 193 | + ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 194 | + $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 195 | + 'args' => [ |
|
| 196 | + 'contexte' => $flux['args']['contexte'], |
|
| 197 | + 'type' => $objet, |
|
| 198 | + 'id' => $id |
|
| 199 | + ], |
|
| 200 | + 'data' => $flux['data']['texte'] |
|
| 201 | + ]); |
|
| 202 | + } |
|
| 203 | + $flux['data']['texte'] = pipeline( |
|
| 204 | + 'affiche_milieu', |
|
| 205 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 206 | + ); |
|
| 207 | + } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 208 | + $flux['data']['texte'] = pipeline( |
|
| 209 | + 'affiche_pied', |
|
| 210 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 211 | + ); |
|
| 212 | + } elseif ( |
|
| 213 | + strncmp($fond, 'prive/objets/contenu/', 21) == 0 |
|
| 214 | + and $objet = basename($fond) |
|
| 215 | + and $objet == substr($fond, 21) |
|
| 216 | + and isset($o[$objet]) |
|
| 217 | + and $o[$objet] |
|
| 218 | + ) { |
|
| 219 | + $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 220 | + $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 221 | + 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 222 | + 'data' => $flux['data']['texte'] |
|
| 223 | + ]); |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - return $flux; |
|
| 227 | + return $flux; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -252,36 +252,36 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string { |
| 254 | 254 | |
| 255 | - if ($texte) { |
|
| 256 | - $encapsuler = (($ouvrir and $fermer) ? true : false); |
|
| 257 | - $marqueur_pos = strpos($texte, $marqueur); |
|
| 258 | - $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 255 | + if ($texte) { |
|
| 256 | + $encapsuler = (($ouvrir and $fermer) ? true : false); |
|
| 257 | + $marqueur_pos = strpos($texte, $marqueur); |
|
| 258 | + $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 259 | 259 | |
| 260 | - // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 261 | - if ($marqueur_pos === false) { |
|
| 262 | - $texte = preg_replace( |
|
| 263 | - ",$inserer_avant,", |
|
| 264 | - "$full_marqueur\\0", |
|
| 265 | - $texte |
|
| 266 | - ); |
|
| 267 | - // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 268 | - // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 269 | - // Il ne faut donc aucun espace blanc en trop. |
|
| 270 | - } elseif ( |
|
| 271 | - $marqueur_pos !== false |
|
| 272 | - and $encapsuler |
|
| 273 | - and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 274 | - ) { |
|
| 275 | - $texte = substr_replace( |
|
| 276 | - $texte, |
|
| 277 | - $full_marqueur, |
|
| 278 | - $marqueur_pos, |
|
| 279 | - strlen($marqueur) |
|
| 280 | - ); |
|
| 281 | - } |
|
| 282 | - } |
|
| 260 | + // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 261 | + if ($marqueur_pos === false) { |
|
| 262 | + $texte = preg_replace( |
|
| 263 | + ",$inserer_avant,", |
|
| 264 | + "$full_marqueur\\0", |
|
| 265 | + $texte |
|
| 266 | + ); |
|
| 267 | + // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 268 | + // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 269 | + // Il ne faut donc aucun espace blanc en trop. |
|
| 270 | + } elseif ( |
|
| 271 | + $marqueur_pos !== false |
|
| 272 | + and $encapsuler |
|
| 273 | + and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 274 | + ) { |
|
| 275 | + $texte = substr_replace( |
|
| 276 | + $texte, |
|
| 277 | + $full_marqueur, |
|
| 278 | + $marqueur_pos, |
|
| 279 | + strlen($marqueur) |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - return $texte; |
|
| 284 | + return $texte; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -292,23 +292,23 @@ discard block |
||
| 292 | 292 | * @return string |
| 293 | 293 | */ |
| 294 | 294 | function f_queue_affiche_milieu($flux) { |
| 295 | - $args = $flux['args']; |
|
| 296 | - $res = ''; |
|
| 297 | - foreach ($args as $key => $arg) { |
|
| 298 | - if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) { |
|
| 299 | - $objet = preg_replace(',^id_,', '', $key); |
|
| 300 | - $res .= recuperer_fond( |
|
| 301 | - 'modeles/object_jobs_list', |
|
| 302 | - ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 303 | - ['ajax' => true] |
|
| 304 | - ); |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - if ($res) { |
|
| 308 | - $flux['data'] = $res . $flux['data']; |
|
| 309 | - } |
|
| 295 | + $args = $flux['args']; |
|
| 296 | + $res = ''; |
|
| 297 | + foreach ($args as $key => $arg) { |
|
| 298 | + if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) { |
|
| 299 | + $objet = preg_replace(',^id_,', '', $key); |
|
| 300 | + $res .= recuperer_fond( |
|
| 301 | + 'modeles/object_jobs_list', |
|
| 302 | + ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 303 | + ['ajax' => true] |
|
| 304 | + ); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + if ($res) { |
|
| 308 | + $flux['data'] = $res . $flux['data']; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - return $flux; |
|
| 311 | + return $flux; |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -322,39 +322,39 @@ discard block |
||
| 322 | 322 | * @return array|bool |
| 323 | 323 | */ |
| 324 | 324 | function trouver_objet_exec(?string $exec) { |
| 325 | - static $objet_exec = []; |
|
| 326 | - if (!$exec) { |
|
| 327 | - return false; |
|
| 328 | - } |
|
| 329 | - // cas particulier |
|
| 330 | - if ($exec === 'infos_perso') { |
|
| 331 | - $exec = 'auteur'; |
|
| 332 | - set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 333 | - } |
|
| 334 | - if (!isset($objet_exec[$exec])) { |
|
| 335 | - $objet_exec[$exec] = false; |
|
| 336 | - $infos = lister_tables_objets_sql(); |
|
| 337 | - foreach ($infos as $t => $info) { |
|
| 338 | - if ($exec === $info['url_edit'] and $info['editable']) { |
|
| 339 | - return $objet_exec[$exec] = [ |
|
| 340 | - 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 341 | - 'table_objet_sql' => $t, |
|
| 342 | - 'table' => $info['table_objet'], |
|
| 343 | - 'type' => $info['type'], |
|
| 344 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 345 | - ]; |
|
| 346 | - } |
|
| 347 | - if ($exec === $info['url_voir']) { |
|
| 348 | - return $objet_exec[$exec] = [ |
|
| 349 | - 'edition' => false, |
|
| 350 | - 'table_objet_sql' => $t, |
|
| 351 | - 'table' => $info['table_objet'], |
|
| 352 | - 'type' => $info['type'], |
|
| 353 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 354 | - ]; |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - } |
|
| 325 | + static $objet_exec = []; |
|
| 326 | + if (!$exec) { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 329 | + // cas particulier |
|
| 330 | + if ($exec === 'infos_perso') { |
|
| 331 | + $exec = 'auteur'; |
|
| 332 | + set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 333 | + } |
|
| 334 | + if (!isset($objet_exec[$exec])) { |
|
| 335 | + $objet_exec[$exec] = false; |
|
| 336 | + $infos = lister_tables_objets_sql(); |
|
| 337 | + foreach ($infos as $t => $info) { |
|
| 338 | + if ($exec === $info['url_edit'] and $info['editable']) { |
|
| 339 | + return $objet_exec[$exec] = [ |
|
| 340 | + 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 341 | + 'table_objet_sql' => $t, |
|
| 342 | + 'table' => $info['table_objet'], |
|
| 343 | + 'type' => $info['type'], |
|
| 344 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 345 | + ]; |
|
| 346 | + } |
|
| 347 | + if ($exec === $info['url_voir']) { |
|
| 348 | + return $objet_exec[$exec] = [ |
|
| 349 | + 'edition' => false, |
|
| 350 | + 'table_objet_sql' => $t, |
|
| 351 | + 'table' => $info['table_objet'], |
|
| 352 | + 'type' => $info['type'], |
|
| 353 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 354 | + ]; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - return $objet_exec[$exec]; |
|
| 359 | + return $objet_exec[$exec]; |
|
| 360 | 360 | } |
@@ -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_log("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 183 | - if (!$ok) { |
|
| 184 | - spip_log("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_log("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 183 | + if (!$ok) { |
|
| 184 | + spip_log("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, $contenu, $a = strlen($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_log("Ecriture fichier $fichier impossible", _LOG_INFO_IMPORTANTE); |
|
| 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, $contenu, $a = strlen($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_log("Ecriture fichier $fichier impossible", _LOG_INFO_IMPORTANTE); |
|
| 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_log('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_log('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,12 +375,12 @@ 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\'); ?> |
|
| 378 | + if ($res = lire_fichier($fichier, $contenu, $options)) { |
|
| 379 | + $contenu = substr((string) $contenu, strlen('<?php die (\'Acces interdit\'); ?> |
|
| 380 | 380 | ')); |
| 381 | - } |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - return $res; |
|
| 383 | + return $res; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -395,25 +395,25 @@ discard block |
||
| 395 | 395 | * Chemin du fichier |
| 396 | 396 | **/ |
| 397 | 397 | function raler_fichier($fichier) { |
| 398 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 399 | - spip_initialisation_suite(); |
|
| 400 | - } |
|
| 401 | - include_spip('inc/minipres'); |
|
| 402 | - $dir = dirname($fichier); |
|
| 403 | - http_response_code(401); |
|
| 404 | - echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 405 | - . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 406 | - . " <a href='" |
|
| 407 | - . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 408 | - . "'>" |
|
| 409 | - . _T('texte_inc_meta_2') |
|
| 410 | - . '</a> ' |
|
| 411 | - . _T( |
|
| 412 | - 'texte_inc_meta_3', |
|
| 413 | - ['repertoire' => joli_repertoire($dir)] |
|
| 414 | - ) |
|
| 415 | - . "</h4>\n"); |
|
| 416 | - exit; |
|
| 398 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 399 | + spip_initialisation_suite(); |
|
| 400 | + } |
|
| 401 | + include_spip('inc/minipres'); |
|
| 402 | + $dir = dirname($fichier); |
|
| 403 | + http_response_code(401); |
|
| 404 | + echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 405 | + . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 406 | + . " <a href='" |
|
| 407 | + . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 408 | + . "'>" |
|
| 409 | + . _T('texte_inc_meta_2') |
|
| 410 | + . '</a> ' |
|
| 411 | + . _T( |
|
| 412 | + 'texte_inc_meta_3', |
|
| 413 | + ['repertoire' => joli_repertoire($dir)] |
|
| 414 | + ) |
|
| 415 | + . "</h4>\n"); |
|
| 416 | + exit; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | |
@@ -428,14 +428,14 @@ discard block |
||
| 428 | 428 | * - true si récent, false sinon |
| 429 | 429 | */ |
| 430 | 430 | function jeune_fichier($fichier, $n) { |
| 431 | - if (!file_exists($fichier)) { |
|
| 432 | - return false; |
|
| 433 | - } |
|
| 434 | - if (!$c = @filemtime($fichier)) { |
|
| 435 | - return false; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - return (time() - $n <= $c); |
|
| 431 | + if (!file_exists($fichier)) { |
|
| 432 | + return false; |
|
| 433 | + } |
|
| 434 | + if (!$c = @filemtime($fichier)) { |
|
| 435 | + return false; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + return (time() - $n <= $c); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -450,22 +450,22 @@ discard block |
||
| 450 | 450 | * - false si on n'arrive pas poser le verrou ou si la suppression échoue |
| 451 | 451 | */ |
| 452 | 452 | function supprimer_fichier($fichier, $lock = true) { |
| 453 | - if (!@file_exists($fichier)) { |
|
| 454 | - return true; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - if ($lock) { |
|
| 458 | - // verrouiller le fichier destination |
|
| 459 | - if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 460 | - return false; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - // liberer le verrou |
|
| 464 | - spip_fclose_unlock($fp); |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - // supprimer |
|
| 468 | - return @unlink($fichier); |
|
| 453 | + if (!@file_exists($fichier)) { |
|
| 454 | + return true; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + if ($lock) { |
|
| 458 | + // verrouiller le fichier destination |
|
| 459 | + if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 460 | + return false; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + // liberer le verrou |
|
| 464 | + spip_fclose_unlock($fp); |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + // supprimer |
|
| 468 | + return @unlink($fichier); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -475,12 +475,12 @@ discard block |
||
| 475 | 475 | * Chemin du fichier |
| 476 | 476 | */ |
| 477 | 477 | function spip_unlink($f) { |
| 478 | - if (!is_dir($f)) { |
|
| 479 | - supprimer_fichier($f, false); |
|
| 480 | - } else { |
|
| 481 | - @unlink("$f/.ok"); |
|
| 482 | - @rmdir($f); |
|
| 483 | - } |
|
| 478 | + if (!is_dir($f)) { |
|
| 479 | + supprimer_fichier($f, false); |
|
| 480 | + } else { |
|
| 481 | + @unlink("$f/.ok"); |
|
| 482 | + @rmdir($f); |
|
| 483 | + } |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -494,26 +494,26 @@ discard block |
||
| 494 | 494 | * The absolute path of the PHP file to invalidate. |
| 495 | 495 | */ |
| 496 | 496 | function spip_clear_opcode_cache($filepath) { |
| 497 | - clearstatcache(true, $filepath); |
|
| 498 | - |
|
| 499 | - // Zend OPcache |
|
| 500 | - if (function_exists('opcache_invalidate')) { |
|
| 501 | - $invalidate = @opcache_invalidate($filepath, true); |
|
| 502 | - // si l'invalidation a echoue lever un flag |
|
| 503 | - if (!$invalidate && !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 504 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 505 | - } |
|
| 506 | - } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 507 | - // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 508 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 509 | - } |
|
| 510 | - // APC. |
|
| 511 | - if (function_exists('apc_delete_file')) { |
|
| 512 | - // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 513 | - // not compiled yet. |
|
| 514 | - // @see http://php.net/apc-delete-file |
|
| 515 | - @apc_delete_file($filepath); |
|
| 516 | - } |
|
| 497 | + clearstatcache(true, $filepath); |
|
| 498 | + |
|
| 499 | + // Zend OPcache |
|
| 500 | + if (function_exists('opcache_invalidate')) { |
|
| 501 | + $invalidate = @opcache_invalidate($filepath, true); |
|
| 502 | + // si l'invalidation a echoue lever un flag |
|
| 503 | + if (!$invalidate && !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 504 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 505 | + } |
|
| 506 | + } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 507 | + // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 508 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 509 | + } |
|
| 510 | + // APC. |
|
| 511 | + if (function_exists('apc_delete_file')) { |
|
| 512 | + // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 513 | + // not compiled yet. |
|
| 514 | + // @see http://php.net/apc-delete-file |
|
| 515 | + @apc_delete_file($filepath); |
|
| 516 | + } |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -536,25 +536,25 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | */ |
| 538 | 538 | function spip_attend_invalidation_opcode_cache($timestamp = null) { |
| 539 | - if ( |
|
| 540 | - function_exists('opcache_get_configuration') |
|
| 541 | - && @ini_get('opcache.enable') |
|
| 542 | - && @ini_get('opcache.validate_timestamps') |
|
| 543 | - && (($duree = (int) @ini_get('opcache.revalidate_freq')) || ($duree = 2)) |
|
| 544 | - && defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 545 | - ) { |
|
| 546 | - $wait = $duree + 1; |
|
| 547 | - if ($timestamp) { |
|
| 548 | - $wait -= (time() - $timestamp); |
|
| 549 | - if ($wait < 0) { |
|
| 550 | - $wait = 0; |
|
| 551 | - } |
|
| 552 | - } |
|
| 553 | - spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 554 | - if ($wait) { |
|
| 555 | - sleep($duree + 1); |
|
| 556 | - } |
|
| 557 | - } |
|
| 539 | + if ( |
|
| 540 | + function_exists('opcache_get_configuration') |
|
| 541 | + && @ini_get('opcache.enable') |
|
| 542 | + && @ini_get('opcache.validate_timestamps') |
|
| 543 | + && (($duree = (int) @ini_get('opcache.revalidate_freq')) || ($duree = 2)) |
|
| 544 | + && defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 545 | + ) { |
|
| 546 | + $wait = $duree + 1; |
|
| 547 | + if ($timestamp) { |
|
| 548 | + $wait -= (time() - $timestamp); |
|
| 549 | + if ($wait < 0) { |
|
| 550 | + $wait = 0; |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 554 | + if ($wait) { |
|
| 555 | + sleep($duree + 1); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | |
@@ -567,26 +567,26 @@ discard block |
||
| 567 | 567 | * @return bool Suppression reussie. |
| 568 | 568 | */ |
| 569 | 569 | function supprimer_repertoire($dir) { |
| 570 | - if (!file_exists($dir)) { |
|
| 571 | - return true; |
|
| 572 | - } |
|
| 573 | - if (!is_dir($dir) || is_link($dir)) { |
|
| 574 | - return @unlink($dir); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - foreach (scandir($dir) as $item) { |
|
| 578 | - if ($item == '.' || $item == '..') { |
|
| 579 | - continue; |
|
| 580 | - } |
|
| 581 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 582 | - @chmod($dir . '/' . $item, 0777); |
|
| 583 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 584 | - return false; |
|
| 585 | - } |
|
| 586 | - }; |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - return @rmdir($dir); |
|
| 570 | + if (!file_exists($dir)) { |
|
| 571 | + return true; |
|
| 572 | + } |
|
| 573 | + if (!is_dir($dir) || is_link($dir)) { |
|
| 574 | + return @unlink($dir); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + foreach (scandir($dir) as $item) { |
|
| 578 | + if ($item == '.' || $item == '..') { |
|
| 579 | + continue; |
|
| 580 | + } |
|
| 581 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 582 | + @chmod($dir . '/' . $item, 0777); |
|
| 583 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 584 | + return false; |
|
| 585 | + } |
|
| 586 | + }; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + return @rmdir($dir); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
@@ -615,57 +615,57 @@ discard block |
||
| 615 | 615 | * Chemin du répertoire créé. |
| 616 | 616 | **/ |
| 617 | 617 | function sous_repertoire($base, $subdir = '', $nobase = false, $tantpis = false) { |
| 618 | - static $dirs = []; |
|
| 619 | - |
|
| 620 | - $base = str_replace('//', '/', $base); |
|
| 621 | - |
|
| 622 | - # suppr le dernier caractere si c'est un / |
|
| 623 | - $base = rtrim($base, '/'); |
|
| 624 | - |
|
| 625 | - if (!strlen($subdir)) { |
|
| 626 | - $n = strrpos($base, '/'); |
|
| 627 | - if ($n === false) { |
|
| 628 | - return $nobase ? '' : ($base . '/'); |
|
| 629 | - } |
|
| 630 | - $subdir = substr($base, $n + 1); |
|
| 631 | - $base = substr($base, 0, $n + 1); |
|
| 632 | - } else { |
|
| 633 | - $base .= '/'; |
|
| 634 | - $subdir = str_replace('/', '', $subdir); |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - $baseaff = $nobase ? '' : $base; |
|
| 638 | - if (isset($dirs[$base . $subdir])) { |
|
| 639 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 643 | - |
|
| 644 | - if (file_exists("$path/.ok")) { |
|
| 645 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - @mkdir($path, _SPIP_CHMOD); |
|
| 649 | - @chmod($path, _SPIP_CHMOD); |
|
| 650 | - |
|
| 651 | - if (is_dir($path) && is_writable($path)) { |
|
| 652 | - @touch("$path/.ok"); |
|
| 653 | - spip_log("creation $base$subdir/"); |
|
| 654 | - |
|
| 655 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 659 | - // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 660 | - spip_log("echec creation $base{$subdir}"); |
|
| 661 | - if ($tantpis) { |
|
| 662 | - return ''; |
|
| 663 | - } |
|
| 664 | - if (!_DIR_RESTREINT) { |
|
| 665 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 666 | - } |
|
| 667 | - $base .= $subdir; |
|
| 668 | - raler_fichier($base . '/.ok'); |
|
| 618 | + static $dirs = []; |
|
| 619 | + |
|
| 620 | + $base = str_replace('//', '/', $base); |
|
| 621 | + |
|
| 622 | + # suppr le dernier caractere si c'est un / |
|
| 623 | + $base = rtrim($base, '/'); |
|
| 624 | + |
|
| 625 | + if (!strlen($subdir)) { |
|
| 626 | + $n = strrpos($base, '/'); |
|
| 627 | + if ($n === false) { |
|
| 628 | + return $nobase ? '' : ($base . '/'); |
|
| 629 | + } |
|
| 630 | + $subdir = substr($base, $n + 1); |
|
| 631 | + $base = substr($base, 0, $n + 1); |
|
| 632 | + } else { |
|
| 633 | + $base .= '/'; |
|
| 634 | + $subdir = str_replace('/', '', $subdir); |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + $baseaff = $nobase ? '' : $base; |
|
| 638 | + if (isset($dirs[$base . $subdir])) { |
|
| 639 | + return $baseaff . $dirs[$base . $subdir]; |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 643 | + |
|
| 644 | + if (file_exists("$path/.ok")) { |
|
| 645 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + @mkdir($path, _SPIP_CHMOD); |
|
| 649 | + @chmod($path, _SPIP_CHMOD); |
|
| 650 | + |
|
| 651 | + if (is_dir($path) && is_writable($path)) { |
|
| 652 | + @touch("$path/.ok"); |
|
| 653 | + spip_log("creation $base$subdir/"); |
|
| 654 | + |
|
| 655 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 659 | + // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 660 | + spip_log("echec creation $base{$subdir}"); |
|
| 661 | + if ($tantpis) { |
|
| 662 | + return ''; |
|
| 663 | + } |
|
| 664 | + if (!_DIR_RESTREINT) { |
|
| 665 | + $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 666 | + } |
|
| 667 | + $base .= $subdir; |
|
| 668 | + raler_fichier($base . '/.ok'); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | |
@@ -698,56 +698,56 @@ discard block |
||
| 698 | 698 | * Chemins des fichiers trouvés. |
| 699 | 699 | **/ |
| 700 | 700 | function preg_files($dir, $pattern = -1 /* AUTO */, $maxfiles = 10000, $recurs = []) { |
| 701 | - $nbfiles = 0; |
|
| 702 | - if ($pattern == -1) { |
|
| 703 | - $pattern = ''; |
|
| 704 | - } |
|
| 705 | - $fichiers = []; |
|
| 706 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 707 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 708 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 709 | - if ($dir == '') { |
|
| 710 | - $dir = '.'; |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 714 | - while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 715 | - if ( |
|
| 716 | - $f[0] != '.' |
|
| 717 | - && $f != 'CVS' |
|
| 718 | - && $f != 'remove.txt' |
|
| 719 | - && is_readable($f = "$dir/$f") |
|
| 720 | - ) { |
|
| 721 | - if (is_file($f)) { |
|
| 722 | - if (!$pattern || preg_match(";$pattern;iS", $f)) { |
|
| 723 | - $fichiers[] = $f; |
|
| 724 | - $nbfiles++; |
|
| 725 | - } |
|
| 726 | - } else { |
|
| 727 | - if (is_dir($f) && is_array($recurs)) { |
|
| 728 | - $rp = @realpath($f); |
|
| 729 | - if (!is_string($rp) || !strlen($rp)) { |
|
| 730 | - $rp = $f; |
|
| 731 | - } # realpath n'est peut etre pas autorise |
|
| 732 | - if (!isset($recurs[$rp])) { |
|
| 733 | - $recurs[$rp] = true; |
|
| 734 | - $beginning = $fichiers; |
|
| 735 | - $end = preg_files( |
|
| 736 | - "$f/", |
|
| 737 | - $pattern, |
|
| 738 | - $maxfiles - $nbfiles, |
|
| 739 | - $recurs |
|
| 740 | - ); |
|
| 741 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 742 | - $nbfiles = count($fichiers); |
|
| 743 | - } |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - closedir($d); |
|
| 749 | - } |
|
| 750 | - sort($fichiers); |
|
| 751 | - |
|
| 752 | - return $fichiers; |
|
| 701 | + $nbfiles = 0; |
|
| 702 | + if ($pattern == -1) { |
|
| 703 | + $pattern = ''; |
|
| 704 | + } |
|
| 705 | + $fichiers = []; |
|
| 706 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 707 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 708 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 709 | + if ($dir == '') { |
|
| 710 | + $dir = '.'; |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 714 | + while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 715 | + if ( |
|
| 716 | + $f[0] != '.' |
|
| 717 | + && $f != 'CVS' |
|
| 718 | + && $f != 'remove.txt' |
|
| 719 | + && is_readable($f = "$dir/$f") |
|
| 720 | + ) { |
|
| 721 | + if (is_file($f)) { |
|
| 722 | + if (!$pattern || preg_match(";$pattern;iS", $f)) { |
|
| 723 | + $fichiers[] = $f; |
|
| 724 | + $nbfiles++; |
|
| 725 | + } |
|
| 726 | + } else { |
|
| 727 | + if (is_dir($f) && is_array($recurs)) { |
|
| 728 | + $rp = @realpath($f); |
|
| 729 | + if (!is_string($rp) || !strlen($rp)) { |
|
| 730 | + $rp = $f; |
|
| 731 | + } # realpath n'est peut etre pas autorise |
|
| 732 | + if (!isset($recurs[$rp])) { |
|
| 733 | + $recurs[$rp] = true; |
|
| 734 | + $beginning = $fichiers; |
|
| 735 | + $end = preg_files( |
|
| 736 | + "$f/", |
|
| 737 | + $pattern, |
|
| 738 | + $maxfiles - $nbfiles, |
|
| 739 | + $recurs |
|
| 740 | + ); |
|
| 741 | + $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 742 | + $nbfiles = count($fichiers); |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + closedir($d); |
|
| 749 | + } |
|
| 750 | + sort($fichiers); |
|
| 751 | + |
|
| 752 | + return $fichiers; |
|
| 753 | 753 | } |
@@ -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_log('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 324 | + spip_log('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 | } |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | $wait = 0; |
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | - spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 553 | + spip_log('Probleme de configuration opcache.revalidate_freq '.$duree.'s : on attend '.$wait.'s', _LOG_INFO_IMPORTANTE); |
|
| 554 | 554 | if ($wait) { |
| 555 | 555 | sleep($duree + 1); |
| 556 | 556 | } |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | if ($item == '.' || $item == '..') { |
| 579 | 579 | continue; |
| 580 | 580 | } |
| 581 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 582 | - @chmod($dir . '/' . $item, 0777); |
|
| 583 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 581 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 582 | + @chmod($dir.'/'.$item, 0777); |
|
| 583 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 584 | 584 | return false; |
| 585 | 585 | } |
| 586 | 586 | }; |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | if (!strlen($subdir)) { |
| 626 | 626 | $n = strrpos($base, '/'); |
| 627 | 627 | if ($n === false) { |
| 628 | - return $nobase ? '' : ($base . '/'); |
|
| 628 | + return $nobase ? '' : ($base.'/'); |
|
| 629 | 629 | } |
| 630 | 630 | $subdir = substr($base, $n + 1); |
| 631 | 631 | $base = substr($base, 0, $n + 1); |
@@ -635,14 +635,14 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | $baseaff = $nobase ? '' : $base; |
| 638 | - if (isset($dirs[$base . $subdir])) { |
|
| 639 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 638 | + if (isset($dirs[$base.$subdir])) { |
|
| 639 | + return $baseaff.$dirs[$base.$subdir]; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 642 | + $path = $base.$subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 643 | 643 | |
| 644 | 644 | if (file_exists("$path/.ok")) { |
| 645 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 645 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | @mkdir($path, _SPIP_CHMOD); |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | @touch("$path/.ok"); |
| 653 | 653 | spip_log("creation $base$subdir/"); |
| 654 | 654 | |
| 655 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 655 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
@@ -662,10 +662,10 @@ discard block |
||
| 662 | 662 | return ''; |
| 663 | 663 | } |
| 664 | 664 | if (!_DIR_RESTREINT) { |
| 665 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 665 | + $base = preg_replace(',^'._DIR_RACINE.',', '', $base); |
|
| 666 | 666 | } |
| 667 | 667 | $base .= $subdir; |
| 668 | - raler_fichier($base . '/.ok'); |
|
| 668 | + raler_fichier($base.'/.ok'); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | $maxfiles - $nbfiles, |
| 739 | 739 | $recurs |
| 740 | 740 | ); |
| 741 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 741 | + $fichiers = array_merge((array) $beginning, (array) $end); |
|
| 742 | 742 | $nbfiles = count($fichiers); |
| 743 | 743 | } |
| 744 | 744 | } |