@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @package SPIP\Core\SQL\Upgrade |
| 21 | 21 | **/ |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | |
@@ -35,49 +35,49 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function maj_timestamp_mysql($tables = null) { |
| 37 | 37 | |
| 38 | - include_spip('base/dump'); |
|
| 39 | - if (is_null($tables)) { |
|
| 40 | - $tables = base_lister_toutes_tables(); |
|
| 41 | - } elseif (is_string($tables)) { |
|
| 42 | - $tables = [$tables]; |
|
| 43 | - } elseif (!is_array($tables)) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 38 | + include_spip('base/dump'); |
|
| 39 | + if (is_null($tables)) { |
|
| 40 | + $tables = base_lister_toutes_tables(); |
|
| 41 | + } elseif (is_string($tables)) { |
|
| 42 | + $tables = [$tables]; |
|
| 43 | + } elseif (!is_array($tables)) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - // rien a faire si base non mysql |
|
| 48 | - if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 47 | + // rien a faire si base non mysql |
|
| 48 | + if (strncmp($GLOBALS['connexions'][0]['type'], 'mysql', 5) !== 0) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | - // forcer le vidage de cache |
|
| 54 | - $trouver_table(''); |
|
| 52 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 53 | + // forcer le vidage de cache |
|
| 54 | + $trouver_table(''); |
|
| 55 | 55 | |
| 56 | - foreach ($tables as $table) { |
|
| 57 | - if (time() >= _TIME_OUT) { |
|
| 58 | - return; |
|
| 59 | - } |
|
| 60 | - if ($desc = $trouver_table($table)) { |
|
| 61 | - $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | - $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | - if ($d) { |
|
| 64 | - spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | - foreach ($desc['field'] as $field => $type) { |
|
| 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]); |
|
| 69 | - $trouver_table(''); |
|
| 70 | - $new_desc = $trouver_table($table); |
|
| 71 | - spip_log( |
|
| 72 | - "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | - 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | - ); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 56 | + foreach ($tables as $table) { |
|
| 57 | + if (time() >= _TIME_OUT) { |
|
| 58 | + return; |
|
| 59 | + } |
|
| 60 | + if ($desc = $trouver_table($table)) { |
|
| 61 | + $fields_corrected = _mysql_remplacements_definitions_table($desc['field']); |
|
| 62 | + $d = array_diff($desc['field'], $fields_corrected); |
|
| 63 | + if ($d) { |
|
| 64 | + spip_log("Table $table TIMESTAMP incorrect", 'maj'); |
|
| 65 | + foreach ($desc['field'] as $field => $type) { |
|
| 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]); |
|
| 69 | + $trouver_table(''); |
|
| 70 | + $new_desc = $trouver_table($table); |
|
| 71 | + spip_log( |
|
| 72 | + "Apres conversion $table : " . var_export($new_desc['field'], true), |
|
| 73 | + 'maj.' . _LOG_INFO_IMPORTANTE |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // forcer le vidage de cache |
|
| 82 | - $trouver_table(''); |
|
| 81 | + // forcer le vidage de cache |
|
| 82 | + $trouver_table(''); |
|
| 83 | 83 | } |
@@ -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'); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Installation |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/acces'); |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | * @return bool |
| 34 | 34 | */ |
| 35 | 35 | function base_determine_autoinc($table, $desc = []) { |
| 36 | - if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | - $autoinc = true; |
|
| 38 | - } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | - $autoinc = false; |
|
| 40 | - } else { |
|
| 41 | - // essayer de faire au mieux ! |
|
| 42 | - $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | - and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | - and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | - } |
|
| 36 | + if ($t = lister_tables_principales() and isset($t[$table])) { |
|
| 37 | + $autoinc = true; |
|
| 38 | + } elseif ($t = lister_tables_auxiliaires() and isset($t[$table])) { |
|
| 39 | + $autoinc = false; |
|
| 40 | + } else { |
|
| 41 | + // essayer de faire au mieux ! |
|
| 42 | + $autoinc = (isset($desc['key']['PRIMARY KEY']) |
|
| 43 | + and strpos($desc['key']['PRIMARY KEY'], ',') === false |
|
| 44 | + and strpos($desc['field'][$desc['key']['PRIMARY KEY']], 'default') === false); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return $autoinc; |
|
| 47 | + return $autoinc; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -61,58 +61,58 @@ discard block |
||
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | 63 | function creer_ou_upgrader_table($table, $desc, $autoinc, $upgrade = false, $serveur = '') { |
| 64 | - #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | - $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | - #if (!$sql_desc) $sql_desc = false; |
|
| 67 | - #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | - if (!$sql_desc) { |
|
| 69 | - if ($autoinc === 'auto') { |
|
| 70 | - $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | - } |
|
| 72 | - #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | - if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | - } |
|
| 76 | - // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | - #if (!$sql_desc) $sql_desc = false; |
|
| 79 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | - if (!$sql_desc) { |
|
| 81 | - // on retente avec un sleep ? |
|
| 82 | - sleep(1); |
|
| 83 | - sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | - $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | - #if (!$sql_desc) $sql_desc = false; |
|
| 86 | - #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | - if (!$sql_desc) { |
|
| 88 | - spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | - // ajouter les champs manquants |
|
| 94 | - // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | - // c'est toujours a faire manuellement |
|
| 96 | - $last = ''; |
|
| 97 | - if (isset($desc['field'])) { |
|
| 98 | - foreach ($desc['field'] as $field => $type) { |
|
| 99 | - if (!isset($sql_desc['field'][$field])) { |
|
| 100 | - sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | - } |
|
| 102 | - $last = $field; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - if (isset($desc['key'])) { |
|
| 106 | - foreach ($desc['key'] as $key => $type) { |
|
| 107 | - // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | - // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | - if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | - sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | - } |
|
| 112 | - $last = $field; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 64 | + #spip_log("creer_ou_upgrader_table table=$table autoinc=$autoinc upgrade=$upgrade","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 65 | + $sql_desc = $upgrade ? sql_showtable($table, true, $serveur) : false; |
|
| 66 | + #if (!$sql_desc) $sql_desc = false; |
|
| 67 | + #spip_log("table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 68 | + if (!$sql_desc) { |
|
| 69 | + if ($autoinc === 'auto') { |
|
| 70 | + $autoinc = base_determine_autoinc($table, $desc); |
|
| 71 | + } |
|
| 72 | + #spip_log("sql_create $table autoinc=$autoinc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 73 | + if (isset($desc['field']) and isset($desc['key'])) { |
|
| 74 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 75 | + } |
|
| 76 | + // verifier la bonne installation de la table (php-fpm es-tu la ?) |
|
| 77 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 78 | + #if (!$sql_desc) $sql_desc = false; |
|
| 79 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 80 | + if (!$sql_desc) { |
|
| 81 | + // on retente avec un sleep ? |
|
| 82 | + sleep(1); |
|
| 83 | + sql_create($table, $desc['field'], $desc['key'], $autoinc, false, $serveur); |
|
| 84 | + $sql_desc = sql_showtable($table, true, $serveur); |
|
| 85 | + #if (!$sql_desc) $sql_desc = false; |
|
| 86 | + #spip_log("Resultat table=$table sql_desc:$sql_desc","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 87 | + if (!$sql_desc) { |
|
| 88 | + spip_log("Echec creation table $table", 'maj' . _LOG_CRITIQUE); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + #spip_log("sql_alter $table ... (on s'en fiche)","dbinstall"._LOG_INFO_IMPORTANTE); |
|
| 93 | + // ajouter les champs manquants |
|
| 94 | + // on ne supprime jamais les champs, car c'est dangereux |
|
| 95 | + // c'est toujours a faire manuellement |
|
| 96 | + $last = ''; |
|
| 97 | + if (isset($desc['field'])) { |
|
| 98 | + foreach ($desc['field'] as $field => $type) { |
|
| 99 | + if (!isset($sql_desc['field'][$field])) { |
|
| 100 | + sql_alter("TABLE $table ADD $field $type" . ($last ? " AFTER $last" : ''), $serveur); |
|
| 101 | + } |
|
| 102 | + $last = $field; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + if (isset($desc['key'])) { |
|
| 106 | + foreach ($desc['key'] as $key => $type) { |
|
| 107 | + // Ne pas oublier les cas des cles non nommees dans la declaration et qui sont retournees |
|
| 108 | + // par le showtable sous la forme d'un index de tableau "KEY $type" et non "KEY" |
|
| 109 | + if (!isset($sql_desc['key'][$key]) and !isset($sql_desc['key']["$key $type"])) { |
|
| 110 | + sql_alter("TABLE $table ADD $key ($type)", $serveur); |
|
| 111 | + } |
|
| 112 | + $last = $field; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -134,26 +134,26 @@ discard block |
||
| 134 | 134 | * @return void |
| 135 | 135 | */ |
| 136 | 136 | function alterer_base($tables_inc, $tables_noinc, $up = false, $serveur = '') { |
| 137 | - if ($up === false) { |
|
| 138 | - $old = false; |
|
| 139 | - $up = []; |
|
| 140 | - } else { |
|
| 141 | - $old = true; |
|
| 142 | - if (!is_array($up)) { |
|
| 143 | - $up = [$up]; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - foreach ($tables_inc as $k => $v) { |
|
| 147 | - if (!$old or in_array($k, $up)) { |
|
| 148 | - creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | - } |
|
| 150 | - } |
|
| 137 | + if ($up === false) { |
|
| 138 | + $old = false; |
|
| 139 | + $up = []; |
|
| 140 | + } else { |
|
| 141 | + $old = true; |
|
| 142 | + if (!is_array($up)) { |
|
| 143 | + $up = [$up]; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + foreach ($tables_inc as $k => $v) { |
|
| 147 | + if (!$old or in_array($k, $up)) { |
|
| 148 | + creer_ou_upgrader_table($k, $v, true, $old, $serveur); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - foreach ($tables_noinc as $k => $v) { |
|
| 153 | - if (!$old or in_array($k, $up)) { |
|
| 154 | - creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | - } |
|
| 156 | - } |
|
| 152 | + foreach ($tables_noinc as $k => $v) { |
|
| 153 | + if (!$old or in_array($k, $up)) { |
|
| 154 | + creer_ou_upgrader_table($k, $v, false, $old, $serveur); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | function creer_base($serveur = '') { |
| 175 | 175 | |
| 176 | - // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | - // de la conformite de la base |
|
| 178 | - // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 176 | + // Note: les mises a jour reexecutent ce code pour s'assurer |
|
| 177 | + // de la conformite de la base |
|
| 178 | + // pas de panique sur "already exists" et "duplicate entry" donc. |
|
| 179 | 179 | |
| 180 | - alterer_base( |
|
| 181 | - lister_tables_principales(), |
|
| 182 | - lister_tables_auxiliaires(), |
|
| 183 | - false, |
|
| 184 | - $serveur |
|
| 185 | - ); |
|
| 180 | + alterer_base( |
|
| 181 | + lister_tables_principales(), |
|
| 182 | + lister_tables_auxiliaires(), |
|
| 183 | + false, |
|
| 184 | + $serveur |
|
| 185 | + ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | * @return void |
| 203 | 203 | */ |
| 204 | 204 | function maj_tables($upgrade_tables = [], $serveur = '') { |
| 205 | - alterer_base( |
|
| 206 | - lister_tables_principales(), |
|
| 207 | - lister_tables_auxiliaires(), |
|
| 208 | - $upgrade_tables, |
|
| 209 | - $serveur |
|
| 210 | - ); |
|
| 205 | + alterer_base( |
|
| 206 | + lister_tables_principales(), |
|
| 207 | + lister_tables_auxiliaires(), |
|
| 208 | + $upgrade_tables, |
|
| 209 | + $serveur |
|
| 210 | + ); |
|
| 211 | 211 | } |
@@ -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 | /** |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | **/ |
| 37 | 37 | function base_repair_dist($titre = '', $reprise = '') { |
| 38 | 38 | |
| 39 | - $res = admin_repair_tables(); |
|
| 40 | - if (!$res) { |
|
| 41 | - $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | - } else { |
|
| 43 | - include_spip('inc/rubriques'); |
|
| 44 | - calculer_rubriques(); |
|
| 45 | - propager_les_secteurs(); |
|
| 46 | - } |
|
| 47 | - include_spip('inc/minipres'); |
|
| 48 | - $res .= pipeline('base_admin_repair', $res); |
|
| 49 | - echo minipres( |
|
| 50 | - _T('texte_tentative_recuperation'), |
|
| 51 | - $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | - ); |
|
| 39 | + $res = admin_repair_tables(); |
|
| 40 | + if (!$res) { |
|
| 41 | + $res = "<div class='error'>" . _T('avis_erreur_mysql') . ' ' . sql_errno() . ': ' . sql_error() . "</div>\n"; |
|
| 42 | + } else { |
|
| 43 | + include_spip('inc/rubriques'); |
|
| 44 | + calculer_rubriques(); |
|
| 45 | + propager_les_secteurs(); |
|
| 46 | + } |
|
| 47 | + include_spip('inc/minipres'); |
|
| 48 | + $res .= pipeline('base_admin_repair', $res); |
|
| 49 | + echo minipres( |
|
| 50 | + _T('texte_tentative_recuperation'), |
|
| 51 | + $res . generer_form_ecrire('accueil', '', '', _T('public:accueil_site')) |
|
| 52 | + ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -63,59 +63,59 @@ discard block |
||
| 63 | 63 | **/ |
| 64 | 64 | function admin_repair_tables() { |
| 65 | 65 | |
| 66 | - $repair = sql_repair('repair', null, 'continue'); |
|
| 66 | + $repair = sql_repair('repair', null, 'continue'); |
|
| 67 | 67 | |
| 68 | - // recreer les tables manquantes eventuelles |
|
| 69 | - include_spip('base/create'); |
|
| 70 | - creer_base(); |
|
| 71 | - $tables = sql_alltable(); |
|
| 68 | + // recreer les tables manquantes eventuelles |
|
| 69 | + include_spip('base/create'); |
|
| 70 | + creer_base(); |
|
| 71 | + $tables = sql_alltable(); |
|
| 72 | 72 | |
| 73 | - $res = ''; |
|
| 74 | - foreach ($tables as $tab) { |
|
| 75 | - $class = ''; |
|
| 76 | - $m = "<strong>$tab</strong> "; |
|
| 77 | - spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | - // supprimer la meta avant de lancer la reparation |
|
| 79 | - // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | - effacer_meta('admin_repair'); |
|
| 81 | - if ($repair) { |
|
| 82 | - $result_repair = sql_repair($tab); |
|
| 83 | - if (!$result_repair) { |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - } |
|
| 73 | + $res = ''; |
|
| 74 | + foreach ($tables as $tab) { |
|
| 75 | + $class = ''; |
|
| 76 | + $m = "<strong>$tab</strong> "; |
|
| 77 | + spip_log("Repare $tab", _LOG_INFO_IMPORTANTE); |
|
| 78 | + // supprimer la meta avant de lancer la reparation |
|
| 79 | + // car le repair peut etre long ; on ne veut pas boucler |
|
| 80 | + effacer_meta('admin_repair'); |
|
| 81 | + if ($repair) { |
|
| 82 | + $result_repair = sql_repair($tab); |
|
| 83 | + if (!$result_repair) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - // essayer de maj la table (creation de champs manquants) |
|
| 89 | - maj_tables($tab); |
|
| 88 | + // essayer de maj la table (creation de champs manquants) |
|
| 89 | + maj_tables($tab); |
|
| 90 | 90 | |
| 91 | - $count = sql_countsel($tab); |
|
| 91 | + $count = sql_countsel($tab); |
|
| 92 | 92 | |
| 93 | - if ($count > 1) { |
|
| 94 | - $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | - } else { |
|
| 96 | - if ($count == 1) { |
|
| 97 | - $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | - } else { |
|
| 99 | - $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | - } |
|
| 101 | - } |
|
| 93 | + if ($count > 1) { |
|
| 94 | + $m .= '(' . _T('texte_compte_elements', ['count' => $count]) . ")\n"; |
|
| 95 | + } else { |
|
| 96 | + if ($count == 1) { |
|
| 97 | + $m .= '(' . _T('texte_compte_element', ['count' => $count]) . ")\n"; |
|
| 98 | + } else { |
|
| 99 | + $m .= '(' . _T('texte_vide') . ")\n"; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - if ( |
|
| 104 | - $result_repair |
|
| 105 | - and $msg = join( |
|
| 106 | - ' ', |
|
| 107 | - (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | - ) . ' ' |
|
| 109 | - and strpos($msg, ' OK ') === false |
|
| 110 | - ) { |
|
| 111 | - $class = " class='notice'"; |
|
| 112 | - $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | - } else { |
|
| 114 | - $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | - } |
|
| 103 | + if ( |
|
| 104 | + $result_repair |
|
| 105 | + and $msg = join( |
|
| 106 | + ' ', |
|
| 107 | + (is_resource($result_repair) or is_object($result_repair)) ? sql_fetch($result_repair) : $result_repair |
|
| 108 | + ) . ' ' |
|
| 109 | + and strpos($msg, ' OK ') === false |
|
| 110 | + ) { |
|
| 111 | + $class = " class='notice'"; |
|
| 112 | + $m .= '<br /><tt>' . spip_htmlentities($msg) . "</tt>\n"; |
|
| 113 | + } else { |
|
| 114 | + $m .= ' ' . _T('texte_table_ok'); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - $res .= "<div$class>$m</div>"; |
|
| 118 | - } |
|
| 117 | + $res .= "<div$class>$m</div>"; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - return $res; |
|
| 120 | + return $res; |
|
| 121 | 121 | } |
@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | define( |
| 18 | - '_REGEXP_DOCTYPE', |
|
| 19 | - '/^((?:<\001?[?][^>]*>\s*)*(?:<!--.*?-->\s*)*)*<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/s' |
|
| 18 | + '_REGEXP_DOCTYPE', |
|
| 19 | + '/^((?:<\001?[?][^>]*>\s*)*(?:<!--.*?-->\s*)*)*<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/s' |
|
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | 22 | define('_REGEXP_XML', '/^(\s*(?:<[?][^x>][^>]*>\s*)?(?:<[?]xml[^>]*>)?\s*(?:<!--.*?-->\s*)*)<(\w+)/s'); |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
| 36 | 36 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 37 | 37 | define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
| 38 | - _SUB_REGEXP_SYMBOL . |
|
| 39 | - '+;?)\s+(' . |
|
| 40 | - _REGEXP_TYPE_XML . |
|
| 41 | - ')?\s*(' . |
|
| 42 | - "('([^']*)')" . |
|
| 43 | - '|("([^"]*)")' . |
|
| 44 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 45 | - ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 38 | + _SUB_REGEXP_SYMBOL . |
|
| 39 | + '+;?)\s+(' . |
|
| 40 | + _REGEXP_TYPE_XML . |
|
| 41 | + ')?\s*(' . |
|
| 42 | + "('([^']*)')" . |
|
| 43 | + '|("([^"]*)")' . |
|
| 44 | + '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 45 | + ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 46 | 46 | |
| 47 | 47 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
| 48 | 48 | |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | * Document Type Compilation |
| 53 | 53 | **/ |
| 54 | 54 | class DTC { |
| 55 | - public $macros = []; |
|
| 56 | - public $elements = []; |
|
| 57 | - public $peres = []; |
|
| 58 | - public $attributs = []; |
|
| 59 | - public $entites = []; |
|
| 60 | - public $regles = []; |
|
| 61 | - public $pcdata = []; |
|
| 55 | + public $macros = []; |
|
| 56 | + public $elements = []; |
|
| 57 | + public $peres = []; |
|
| 58 | + public $attributs = []; |
|
| 59 | + public $entites = []; |
|
| 60 | + public $regles = []; |
|
| 61 | + public $pcdata = []; |
|
| 62 | 62 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -36,22 +36,22 @@ discard block |
||
| 36 | 36 | * Description de la boucle complétée des champs |
| 37 | 37 | */ |
| 38 | 38 | function iterateur_php_dist($b, $iteratorName) { |
| 39 | - $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | - $b->show = [ |
|
| 41 | - 'field' => [ |
|
| 42 | - 'cle' => 'STRING', |
|
| 43 | - 'valeur' => 'STRING', |
|
| 44 | - ] |
|
| 45 | - ]; |
|
| 46 | - foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | - $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /* |
|
| 39 | + $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | + $b->show = [ |
|
| 41 | + 'field' => [ |
|
| 42 | + 'cle' => 'STRING', |
|
| 43 | + 'valeur' => 'STRING', |
|
| 44 | + ] |
|
| 45 | + ]; |
|
| 46 | + foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | + $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /* |
|
| 51 | 51 | foreach (get_class_vars($iteratorName) as $property) { |
| 52 | 52 | $b->show['field'][ strtolower($property) ] = 'PROPERTY'; |
| 53 | 53 | } |
| 54 | 54 | */ |
| 55 | 55 | |
| 56 | - return $b; |
|
| 56 | + return $b; |
|
| 57 | 57 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('iterateur/data'); |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | * Description de la boucle complétée des champs |
| 40 | 40 | */ |
| 41 | 41 | function iterateur_POUR_dist($b) { |
| 42 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 43 | - $b->show = [ |
|
| 44 | - 'field' => [ |
|
| 45 | - 'cle' => 'STRING', |
|
| 46 | - 'valeur' => 'STRING', |
|
| 47 | - ] |
|
| 48 | - ]; |
|
| 42 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 43 | + $b->show = [ |
|
| 44 | + 'field' => [ |
|
| 45 | + 'cle' => 'STRING', |
|
| 46 | + 'valeur' => 'STRING', |
|
| 47 | + ] |
|
| 48 | + ]; |
|
| 49 | 49 | |
| 50 | - return $b; |
|
| 50 | + return $b; |
|
| 51 | 51 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('iterateur/data'); |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | * Description de la boucle complétée des champs |
| 36 | 36 | */ |
| 37 | 37 | function iterateur_CONDITION_dist($b) { |
| 38 | - $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 39 | - $b->show = [ |
|
| 40 | - 'field' => [] |
|
| 41 | - ]; |
|
| 38 | + $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 39 | + $b->show = [ |
|
| 40 | + 'field' => [] |
|
| 41 | + ]; |
|
| 42 | 42 | |
| 43 | - return $b; |
|
| 43 | + return $b; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | * La boucle condition n'a toujours qu'un seul élément. |
| 50 | 50 | */ |
| 51 | 51 | class IterateurCONDITION extends IterateurData { |
| 52 | - /** |
|
| 53 | - * Obtenir les données de la boucle CONDITION |
|
| 54 | - * |
|
| 55 | - * @param array $command |
|
| 56 | - **/ |
|
| 57 | - protected function select($command) { |
|
| 58 | - $this->tableau = [0 => 1]; |
|
| 59 | - } |
|
| 52 | + /** |
|
| 53 | + * Obtenir les données de la boucle CONDITION |
|
| 54 | + * |
|
| 55 | + * @param array $command |
|
| 56 | + **/ |
|
| 57 | + protected function select($command) { |
|
| 58 | + $this->tableau = [0 => 1]; |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -11,77 +11,77 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // https://code.spip.net/@install_etape_ldap2_dist |
| 18 | 18 | function install_etape_ldap2_dist() { |
| 19 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 19 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 20 | 20 | |
| 21 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | 22 | |
| 23 | - $port_ldap = _request('port_ldap'); |
|
| 23 | + $port_ldap = _request('port_ldap'); |
|
| 24 | 24 | |
| 25 | - $tls_ldap = _request('tls_ldap'); |
|
| 25 | + $tls_ldap = _request('tls_ldap'); |
|
| 26 | 26 | |
| 27 | - $protocole_ldap = _request('protocole_ldap'); |
|
| 27 | + $protocole_ldap = _request('protocole_ldap'); |
|
| 28 | 28 | |
| 29 | - $login_ldap = _request('login_ldap'); |
|
| 29 | + $login_ldap = _request('login_ldap'); |
|
| 30 | 30 | |
| 31 | - $pass_ldap = _request('pass_ldap'); |
|
| 31 | + $pass_ldap = _request('pass_ldap'); |
|
| 32 | 32 | |
| 33 | - $port_ldap = intval($port_ldap); |
|
| 33 | + $port_ldap = intval($port_ldap); |
|
| 34 | 34 | |
| 35 | - $tls = false; |
|
| 35 | + $tls = false; |
|
| 36 | 36 | |
| 37 | - if ($tls_ldap == 'oui') { |
|
| 38 | - if ($port_ldap == 636) { |
|
| 39 | - $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 40 | - } else { |
|
| 41 | - $tls = true; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 45 | - $erreur = "ldap_connect($adresse_ldap, $port_ldap)"; |
|
| 37 | + if ($tls_ldap == 'oui') { |
|
| 38 | + if ($port_ldap == 636) { |
|
| 39 | + $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 40 | + } else { |
|
| 41 | + $tls = true; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 45 | + $erreur = "ldap_connect($adresse_ldap, $port_ldap)"; |
|
| 46 | 46 | |
| 47 | - if ($ldap_link) { |
|
| 48 | - if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 49 | - $protocole_ldap = 2; |
|
| 50 | - ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 51 | - } |
|
| 52 | - if ($tls === true) { |
|
| 53 | - if (!ldap_start_tls($ldap_link)) { |
|
| 54 | - $erreur = "ldap_start_tls($ldap_link) $adresse_ldap, $port_ldap"; |
|
| 55 | - $ldap_link = false; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - if ($ldap_link) { |
|
| 59 | - $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 60 | - $erreur = "ldap_bind('$ldap_link', '$login_ldap', '$pass_ldap'): $adresse_ldap, $port_ldap"; |
|
| 61 | - } |
|
| 62 | - } |
|
| 47 | + if ($ldap_link) { |
|
| 48 | + if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 49 | + $protocole_ldap = 2; |
|
| 50 | + ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 51 | + } |
|
| 52 | + if ($tls === true) { |
|
| 53 | + if (!ldap_start_tls($ldap_link)) { |
|
| 54 | + $erreur = "ldap_start_tls($ldap_link) $adresse_ldap, $port_ldap"; |
|
| 55 | + $ldap_link = false; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + if ($ldap_link) { |
|
| 59 | + $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 60 | + $erreur = "ldap_bind('$ldap_link', '$login_ldap', '$pass_ldap'): $adresse_ldap, $port_ldap"; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - if ($ldap_link) { |
|
| 65 | - echo info_etape( |
|
| 66 | - _T('titre_connexion_ldap'), |
|
| 67 | - info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 68 | - ), _T('info_connexion_ldap_ok'); |
|
| 69 | - echo generer_form_ecrire('install', ( |
|
| 70 | - "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 71 | - . "\n<input type='hidden' name='adresse_ldap' value=\"$adresse_ldap\" />" |
|
| 72 | - . "\n<input type='hidden' name='port_ldap' value=\"$port_ldap\" />" |
|
| 73 | - . "\n<input type='hidden' name='login_ldap' value=\"$login_ldap\" />" |
|
| 74 | - . "\n<input type='hidden' name='pass_ldap' value=\"$pass_ldap\" />" |
|
| 75 | - . "\n<input type='hidden' name='protocole_ldap' value=\"$protocole_ldap\" />" |
|
| 76 | - . "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />" |
|
| 77 | - . bouton_suivant())); |
|
| 78 | - } else { |
|
| 79 | - echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 80 | - "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 81 | - '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 82 | - "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 83 | - '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 84 | - } |
|
| 64 | + if ($ldap_link) { |
|
| 65 | + echo info_etape( |
|
| 66 | + _T('titre_connexion_ldap'), |
|
| 67 | + info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 68 | + ), _T('info_connexion_ldap_ok'); |
|
| 69 | + echo generer_form_ecrire('install', ( |
|
| 70 | + "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 71 | + . "\n<input type='hidden' name='adresse_ldap' value=\"$adresse_ldap\" />" |
|
| 72 | + . "\n<input type='hidden' name='port_ldap' value=\"$port_ldap\" />" |
|
| 73 | + . "\n<input type='hidden' name='login_ldap' value=\"$login_ldap\" />" |
|
| 74 | + . "\n<input type='hidden' name='pass_ldap' value=\"$pass_ldap\" />" |
|
| 75 | + . "\n<input type='hidden' name='protocole_ldap' value=\"$protocole_ldap\" />" |
|
| 76 | + . "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />" |
|
| 77 | + . bouton_suivant())); |
|
| 78 | + } else { |
|
| 79 | + echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 80 | + "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 81 | + '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 82 | + "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 83 | + '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - echo install_fin_html(); |
|
| 86 | + echo install_fin_html(); |
|
| 87 | 87 | } |