@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -40,54 +40,54 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function action_referencer_traduction_dist($objet, $id_objet, $id_trad) { |
| 42 | 42 | |
| 43 | - // ne rien faire si id_trad est ambigu |
|
| 44 | - if (!is_numeric($id_trad)) { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 43 | + // ne rien faire si id_trad est ambigu |
|
| 44 | + if (!is_numeric($id_trad)) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $table_objet_sql = table_objet_sql($objet); |
|
| 49 | - $id_table_objet = id_table_objet($objet); |
|
| 48 | + $table_objet_sql = table_objet_sql($objet); |
|
| 49 | + $id_table_objet = id_table_objet($objet); |
|
| 50 | 50 | |
| 51 | - // on a fourni un id_trad : affectation ou modification du groupe de trad |
|
| 52 | - if ($id_trad) { |
|
| 53 | - // selectionner l'objet cible, qui doit etre different de nous-meme, |
|
| 54 | - // et quitter s'il n'existe pas |
|
| 55 | - $id_lier = sql_getfetsel( |
|
| 56 | - 'id_trad', |
|
| 57 | - $table_objet_sql, |
|
| 58 | - "$id_table_objet=" . (int) $id_trad . " AND NOT($id_table_objet=" . (int) $id_objet . ')' |
|
| 59 | - ); |
|
| 60 | - if ($id_lier === null) { |
|
| 61 | - spip_log("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
|
| 51 | + // on a fourni un id_trad : affectation ou modification du groupe de trad |
|
| 52 | + if ($id_trad) { |
|
| 53 | + // selectionner l'objet cible, qui doit etre different de nous-meme, |
|
| 54 | + // et quitter s'il n'existe pas |
|
| 55 | + $id_lier = sql_getfetsel( |
|
| 56 | + 'id_trad', |
|
| 57 | + $table_objet_sql, |
|
| 58 | + "$id_table_objet=" . (int) $id_trad . " AND NOT($id_table_objet=" . (int) $id_objet . ')' |
|
| 59 | + ); |
|
| 60 | + if ($id_lier === null) { |
|
| 61 | + spip_log("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
|
| 62 | 62 | |
| 63 | - return false; |
|
| 64 | - } |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // $id_lier est le numero du groupe de traduction |
|
| 67 | - // Si l'objet vise n'est pas deja traduit, son identifiant devient |
|
| 68 | - // le nouvel id_trad de ce nouveau groupe et on l'affecte aux deux |
|
| 69 | - // objets |
|
| 70 | - if ($id_lier == 0) { |
|
| 71 | - sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "$id_table_objet IN ($id_trad, $id_objet)"); |
|
| 72 | - } // si id_lier = id_objet alors on veut changer la reference de tout le groupe de trad |
|
| 73 | - elseif ($id_lier == $id_objet) { |
|
| 74 | - sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
|
| 75 | - } // sinon ajouter notre objet dans le groupe |
|
| 76 | - else { |
|
| 77 | - sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . (int) $id_objet); |
|
| 78 | - } |
|
| 79 | - } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
|
| 80 | - else { |
|
| 81 | - $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . (int) $id_objet); |
|
| 82 | - // supprimer le lien de traduction |
|
| 83 | - sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . (int) $id_objet); |
|
| 66 | + // $id_lier est le numero du groupe de traduction |
|
| 67 | + // Si l'objet vise n'est pas deja traduit, son identifiant devient |
|
| 68 | + // le nouvel id_trad de ce nouveau groupe et on l'affecte aux deux |
|
| 69 | + // objets |
|
| 70 | + if ($id_lier == 0) { |
|
| 71 | + sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "$id_table_objet IN ($id_trad, $id_objet)"); |
|
| 72 | + } // si id_lier = id_objet alors on veut changer la reference de tout le groupe de trad |
|
| 73 | + elseif ($id_lier == $id_objet) { |
|
| 74 | + sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
|
| 75 | + } // sinon ajouter notre objet dans le groupe |
|
| 76 | + else { |
|
| 77 | + sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . (int) $id_objet); |
|
| 78 | + } |
|
| 79 | + } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
|
| 80 | + else { |
|
| 81 | + $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . (int) $id_objet); |
|
| 82 | + // supprimer le lien de traduction |
|
| 83 | + sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . (int) $id_objet); |
|
| 84 | 84 | |
| 85 | - // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
|
| 86 | - $cpt = sql_countsel($table_objet_sql, 'id_trad=' . (int) $old_id_trad); |
|
| 87 | - if ($cpt == 1) { |
|
| 88 | - sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . (int) $old_id_trad); |
|
| 89 | - } |
|
| 90 | - } |
|
| 85 | + // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
|
| 86 | + $cpt = sql_countsel($table_objet_sql, 'id_trad=' . (int) $old_id_trad); |
|
| 87 | + if ($cpt == 1) { |
|
| 88 | + sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . (int) $old_id_trad); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return true; |
|
| 92 | + return true; |
|
| 93 | 93 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $id_lier = sql_getfetsel( |
| 56 | 56 | 'id_trad', |
| 57 | 57 | $table_objet_sql, |
| 58 | - "$id_table_objet=" . (int) $id_trad . " AND NOT($id_table_objet=" . (int) $id_objet . ')' |
|
| 58 | + "$id_table_objet=".(int) $id_trad." AND NOT($id_table_objet=".(int) $id_objet.')' |
|
| 59 | 59 | ); |
| 60 | 60 | if ($id_lier === null) { |
| 61 | 61 | spip_log("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
| 75 | 75 | } // sinon ajouter notre objet dans le groupe |
| 76 | 76 | else { |
| 77 | - sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . (int) $id_objet); |
|
| 77 | + sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=".(int) $id_objet); |
|
| 78 | 78 | } |
| 79 | 79 | } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
| 80 | 80 | else { |
| 81 | - $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . (int) $id_objet); |
|
| 81 | + $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=".(int) $id_objet); |
|
| 82 | 82 | // supprimer le lien de traduction |
| 83 | - sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . (int) $id_objet); |
|
| 83 | + sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=".(int) $id_objet); |
|
| 84 | 84 | |
| 85 | 85 | // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
| 86 | - $cpt = sql_countsel($table_objet_sql, 'id_trad=' . (int) $old_id_trad); |
|
| 86 | + $cpt = sql_countsel($table_objet_sql, 'id_trad='.(int) $old_id_trad); |
|
| 87 | 87 | if ($cpt == 1) { |
| 88 | - sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . (int) $old_id_trad); |
|
| 88 | + sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad='.(int) $old_id_trad); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']); |
| 76 | 76 | if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) { |
| 77 | 77 | $t *= 0.9; // marge de securite |
| 78 | - echo round($t / 1_000_000, 3) . ' Mpx'; |
|
| 78 | + echo round($t / 1_000_000, 3).' Mpx'; |
|
| 79 | 79 | } else { |
| 80 | 80 | // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue" |
| 81 | 81 | $t = 0; |
@@ -111,19 +111,19 @@ discard block |
||
| 111 | 111 | $image_source = chemin_image('test.png'); |
| 112 | 112 | $GLOBALS['redirect'] = generer_url_action( |
| 113 | 113 | 'tester_taille', |
| 114 | - "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test'] |
|
| 114 | + "i=$i&arg=".$GLOBALS['taille_min'].'-'.$GLOBALS['taille_test'] |
|
| 115 | 115 | ); |
| 116 | 116 | |
| 117 | 117 | ob_start('action_tester_taille_error_handler'); |
| 118 | 118 | filtrer('image_recadre', $image_source, $taille, $taille); |
| 119 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 119 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
|
| 120 | 120 | |
| 121 | 121 | // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
| 122 | 122 | // si $GLOBALS['taille_min']==0 (car on est au premier coup) |
| 123 | 123 | if ($GLOBALS['taille_min'] == 0) { |
| 124 | 124 | $taille = $GLOBALS['taille_max']; |
| 125 | 125 | filtrer('image_recadre', $image_source, $taille, $taille); |
| 126 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 126 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-".$GLOBALS['taille_max']); |
|
| 127 | 127 | } |
| 128 | 128 | ob_end_clean(); |
| 129 | 129 | |
@@ -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 | include_spip('inc/headers'); |
| 23 | 23 | |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | * Sortie du buffer |
| 35 | 35 | **/ |
| 36 | 36 | function action_tester_taille_error_handler($output) { |
| 37 | - // on est ici, donc echec lors de la creation de l'image |
|
| 38 | - if (!empty($GLOBALS['redirect'])) { |
|
| 39 | - return redirige_formulaire($GLOBALS['redirect']); |
|
| 40 | - } |
|
| 37 | + // on est ici, donc echec lors de la creation de l'image |
|
| 38 | + if (!empty($GLOBALS['redirect'])) { |
|
| 39 | + return redirige_formulaire($GLOBALS['redirect']); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return $output; |
|
| 42 | + return $output; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -57,77 +57,77 @@ discard block |
||
| 57 | 57 | **/ |
| 58 | 58 | function action_tester_taille_dist() { |
| 59 | 59 | |
| 60 | - if (!autoriser('configurer')) { |
|
| 61 | - return; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - $taille = _request('arg'); |
|
| 65 | - $taille = explode('-', (string) $taille); |
|
| 66 | - |
|
| 67 | - $GLOBALS['taille_max'] = end($taille); |
|
| 68 | - $GLOBALS['taille_min'] = 0; |
|
| 69 | - if (count($taille) > 1) { |
|
| 70 | - $GLOBALS['taille_min'] = reset($taille); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // si l'intervalle est assez petit, on garde la valeur min |
|
| 74 | - if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) { |
|
| 75 | - $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']); |
|
| 76 | - if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) { |
|
| 77 | - $t *= 0.9; // marge de securite |
|
| 78 | - echo round($t / 1_000_000, 3) . ' Mpx'; |
|
| 79 | - } else { |
|
| 80 | - // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue" |
|
| 81 | - $t = 0; |
|
| 82 | - echo '∞'; |
|
| 83 | - } |
|
| 84 | - ecrire_meta('max_taille_vignettes', $t, 'non'); |
|
| 85 | - die(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2); |
|
| 89 | - |
|
| 90 | - include_spip('inc/filtres'); |
|
| 91 | - // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 92 | - include_spip('public/assembler'); |
|
| 93 | - include_spip('public/balises'); |
|
| 94 | - include_spip('public/boucles'); |
|
| 95 | - include_spip('public/cacher'); |
|
| 96 | - include_spip('public/compiler'); |
|
| 97 | - include_spip('public/composer'); |
|
| 98 | - include_spip('public/criteres'); |
|
| 99 | - include_spip('public/interfaces'); |
|
| 100 | - include_spip('public/parametrer'); |
|
| 101 | - include_spip('public/phraser_html'); |
|
| 102 | - include_spip('public/references'); |
|
| 103 | - |
|
| 104 | - include_spip('inc/presentation'); |
|
| 105 | - include_spip('inc/charsets'); |
|
| 106 | - include_spip('inc/documents'); |
|
| 107 | - include_spip('inc/header'); |
|
| 108 | - propre('<doc1>'); // charger propre avec le trairement d'un modele |
|
| 109 | - |
|
| 110 | - $i = _request('i') + 1; |
|
| 111 | - $image_source = chemin_image('test.png'); |
|
| 112 | - $GLOBALS['redirect'] = generer_url_action( |
|
| 113 | - 'tester_taille', |
|
| 114 | - "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test'] |
|
| 115 | - ); |
|
| 116 | - |
|
| 117 | - ob_start('action_tester_taille_error_handler'); |
|
| 118 | - filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 119 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 120 | - |
|
| 121 | - // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 122 | - // si $GLOBALS['taille_min']==0 (car on est au premier coup) |
|
| 123 | - if ($GLOBALS['taille_min'] == 0) { |
|
| 124 | - $taille = $GLOBALS['taille_max']; |
|
| 125 | - filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 126 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 127 | - } |
|
| 128 | - ob_end_clean(); |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - // on est ici, donc pas de plantage |
|
| 132 | - echo redirige_formulaire($GLOBALS['redirect']); |
|
| 60 | + if (!autoriser('configurer')) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + $taille = _request('arg'); |
|
| 65 | + $taille = explode('-', (string) $taille); |
|
| 66 | + |
|
| 67 | + $GLOBALS['taille_max'] = end($taille); |
|
| 68 | + $GLOBALS['taille_min'] = 0; |
|
| 69 | + if (count($taille) > 1) { |
|
| 70 | + $GLOBALS['taille_min'] = reset($taille); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // si l'intervalle est assez petit, on garde la valeur min |
|
| 74 | + if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) { |
|
| 75 | + $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']); |
|
| 76 | + if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) { |
|
| 77 | + $t *= 0.9; // marge de securite |
|
| 78 | + echo round($t / 1_000_000, 3) . ' Mpx'; |
|
| 79 | + } else { |
|
| 80 | + // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue" |
|
| 81 | + $t = 0; |
|
| 82 | + echo '∞'; |
|
| 83 | + } |
|
| 84 | + ecrire_meta('max_taille_vignettes', $t, 'non'); |
|
| 85 | + die(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2); |
|
| 89 | + |
|
| 90 | + include_spip('inc/filtres'); |
|
| 91 | + // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 92 | + include_spip('public/assembler'); |
|
| 93 | + include_spip('public/balises'); |
|
| 94 | + include_spip('public/boucles'); |
|
| 95 | + include_spip('public/cacher'); |
|
| 96 | + include_spip('public/compiler'); |
|
| 97 | + include_spip('public/composer'); |
|
| 98 | + include_spip('public/criteres'); |
|
| 99 | + include_spip('public/interfaces'); |
|
| 100 | + include_spip('public/parametrer'); |
|
| 101 | + include_spip('public/phraser_html'); |
|
| 102 | + include_spip('public/references'); |
|
| 103 | + |
|
| 104 | + include_spip('inc/presentation'); |
|
| 105 | + include_spip('inc/charsets'); |
|
| 106 | + include_spip('inc/documents'); |
|
| 107 | + include_spip('inc/header'); |
|
| 108 | + propre('<doc1>'); // charger propre avec le trairement d'un modele |
|
| 109 | + |
|
| 110 | + $i = _request('i') + 1; |
|
| 111 | + $image_source = chemin_image('test.png'); |
|
| 112 | + $GLOBALS['redirect'] = generer_url_action( |
|
| 113 | + 'tester_taille', |
|
| 114 | + "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test'] |
|
| 115 | + ); |
|
| 116 | + |
|
| 117 | + ob_start('action_tester_taille_error_handler'); |
|
| 118 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 119 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 120 | + |
|
| 121 | + // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 122 | + // si $GLOBALS['taille_min']==0 (car on est au premier coup) |
|
| 123 | + if ($GLOBALS['taille_min'] == 0) { |
|
| 124 | + $taille = $GLOBALS['taille_max']; |
|
| 125 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 126 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 127 | + } |
|
| 128 | + ob_end_clean(); |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + // on est ici, donc pas de plantage |
|
| 132 | + echo redirige_formulaire($GLOBALS['redirect']); |
|
| 133 | 133 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/charsets'); # pour le nom de fichier |
@@ -29,45 +29,45 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function action_supprimer_rubrique_dist($id_rubrique = null) { |
| 31 | 31 | |
| 32 | - if (is_null($id_rubrique)) { |
|
| 33 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 34 | - $id_rubrique = $securiser_action(); |
|
| 35 | - } |
|
| 32 | + if (is_null($id_rubrique)) { |
|
| 33 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 34 | + $id_rubrique = $securiser_action(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - if ((int) $id_rubrique) { |
|
| 38 | - sql_delete('spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 39 | - // Les admin restreints qui n'administraient que cette rubrique |
|
| 40 | - // deviennent redacteurs |
|
| 41 | - // (il y a sans doute moyen de faire ca avec un having) |
|
| 37 | + if ((int) $id_rubrique) { |
|
| 38 | + sql_delete('spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 39 | + // Les admin restreints qui n'administraient que cette rubrique |
|
| 40 | + // deviennent redacteurs |
|
| 41 | + // (il y a sans doute moyen de faire ca avec un having) |
|
| 42 | 42 | |
| 43 | - $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=" . (int) $id_rubrique); |
|
| 44 | - while ($r = sql_fetch($q)) { |
|
| 45 | - $id_auteur = $r['id_auteur']; |
|
| 46 | - // degrader avant de supprimer la restriction d'admin |
|
| 47 | - // section critique sur les droits |
|
| 48 | - $n = sql_countsel( |
|
| 49 | - 'spip_auteurs_liens', |
|
| 50 | - "objet='rubrique' AND id_objet!=" . (int) $id_rubrique . ' AND id_auteur=' . (int) $id_auteur |
|
| 51 | - ); |
|
| 52 | - if (!$n) { |
|
| 53 | - include_spip('action/editer_auteur'); |
|
| 54 | - auteur_modifier($id_auteur, ['statut' => '1comite']); |
|
| 55 | - } |
|
| 56 | - sql_delete( |
|
| 57 | - 'spip_auteurs_liens', |
|
| 58 | - "objet='rubrique' AND id_objet=" . (int) $id_rubrique . ' AND id_auteur=' . (int) $id_auteur |
|
| 59 | - ); |
|
| 60 | - } |
|
| 61 | - // menu_rubriques devra recalculer |
|
| 62 | - effacer_meta('date_calcul_rubriques'); |
|
| 43 | + $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=" . (int) $id_rubrique); |
|
| 44 | + while ($r = sql_fetch($q)) { |
|
| 45 | + $id_auteur = $r['id_auteur']; |
|
| 46 | + // degrader avant de supprimer la restriction d'admin |
|
| 47 | + // section critique sur les droits |
|
| 48 | + $n = sql_countsel( |
|
| 49 | + 'spip_auteurs_liens', |
|
| 50 | + "objet='rubrique' AND id_objet!=" . (int) $id_rubrique . ' AND id_auteur=' . (int) $id_auteur |
|
| 51 | + ); |
|
| 52 | + if (!$n) { |
|
| 53 | + include_spip('action/editer_auteur'); |
|
| 54 | + auteur_modifier($id_auteur, ['statut' => '1comite']); |
|
| 55 | + } |
|
| 56 | + sql_delete( |
|
| 57 | + 'spip_auteurs_liens', |
|
| 58 | + "objet='rubrique' AND id_objet=" . (int) $id_rubrique . ' AND id_auteur=' . (int) $id_auteur |
|
| 59 | + ); |
|
| 60 | + } |
|
| 61 | + // menu_rubriques devra recalculer |
|
| 62 | + effacer_meta('date_calcul_rubriques'); |
|
| 63 | 63 | |
| 64 | - // Une rubrique supprimable n'avait pas le statut "publie" |
|
| 65 | - // donc rien de neuf pour la rubrique parente |
|
| 66 | - include_spip('inc/rubriques'); |
|
| 67 | - calculer_langues_rubriques(); |
|
| 64 | + // Une rubrique supprimable n'avait pas le statut "publie" |
|
| 65 | + // donc rien de neuf pour la rubrique parente |
|
| 66 | + include_spip('inc/rubriques'); |
|
| 67 | + calculer_langues_rubriques(); |
|
| 68 | 68 | |
| 69 | - // invalider les caches marques de cette rubrique |
|
| 70 | - include_spip('inc/invalideur'); |
|
| 71 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 72 | - } |
|
| 69 | + // invalider les caches marques de cette rubrique |
|
| 70 | + include_spip('inc/invalideur'); |
|
| 71 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -include_spip('inc/charsets'); # pour le nom de fichier |
|
| 22 | +include_spip('inc/charsets'); # pour le nom de fichier |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * Effacer une rubrique |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | if ((int) $id_rubrique) { |
| 38 | - sql_delete('spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 38 | + sql_delete('spip_rubriques', 'id_rubrique='.(int) $id_rubrique); |
|
| 39 | 39 | // Les admin restreints qui n'administraient que cette rubrique |
| 40 | 40 | // deviennent redacteurs |
| 41 | 41 | // (il y a sans doute moyen de faire ca avec un having) |
| 42 | 42 | |
| 43 | - $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=" . (int) $id_rubrique); |
|
| 43 | + $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=".(int) $id_rubrique); |
|
| 44 | 44 | while ($r = sql_fetch($q)) { |
| 45 | 45 | $id_auteur = $r['id_auteur']; |
| 46 | 46 | // degrader avant de supprimer la restriction d'admin |
| 47 | 47 | // section critique sur les droits |
| 48 | 48 | $n = sql_countsel( |
| 49 | 49 | 'spip_auteurs_liens', |
| 50 | - "objet='rubrique' AND id_objet!=" . (int) $id_rubrique . ' AND id_auteur=' . (int) $id_auteur |
|
| 50 | + "objet='rubrique' AND id_objet!=".(int) $id_rubrique.' AND id_auteur='.(int) $id_auteur |
|
| 51 | 51 | ); |
| 52 | 52 | if (!$n) { |
| 53 | 53 | include_spip('action/editer_auteur'); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | sql_delete( |
| 57 | 57 | 'spip_auteurs_liens', |
| 58 | - "objet='rubrique' AND id_objet=" . (int) $id_rubrique . ' AND id_auteur=' . (int) $id_auteur |
|
| 58 | + "objet='rubrique' AND id_objet=".(int) $id_rubrique.' AND id_auteur='.(int) $id_auteur |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | // menu_rubriques devra recalculer |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | && $_SERVER['REQUEST_METHOD'] == 'POST' |
| 38 | 38 | ) { |
| 39 | 39 | include_spip('inc/session'); |
| 40 | - session_set('session_' . $var, $val = _request('val')); |
|
| 40 | + session_set('session_'.$var, $val = _request('val')); |
|
| 41 | 41 | #spip_log("autosave:$var:$val",'autosave'); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -31,16 +31,16 @@ discard block |
||
| 31 | 31 | * Envoyer en réponse : json contenant toutes les variables publiques de la session |
| 32 | 32 | **/ |
| 33 | 33 | function action_session_dist() { |
| 34 | - if ( |
|
| 35 | - ($var = _request('var')) |
|
| 36 | - && preg_match(',^[a-z_0-9-]+$,i', (string) $var) |
|
| 37 | - && $_SERVER['REQUEST_METHOD'] == 'POST' |
|
| 38 | - ) { |
|
| 39 | - include_spip('inc/session'); |
|
| 40 | - session_set('session_' . $var, $val = _request('val')); |
|
| 41 | - #spip_log("autosave:$var:$val",'autosave'); |
|
| 42 | - } |
|
| 34 | + if ( |
|
| 35 | + ($var = _request('var')) |
|
| 36 | + && preg_match(',^[a-z_0-9-]+$,i', (string) $var) |
|
| 37 | + && $_SERVER['REQUEST_METHOD'] == 'POST' |
|
| 38 | + ) { |
|
| 39 | + include_spip('inc/session'); |
|
| 40 | + session_set('session_' . $var, $val = _request('val')); |
|
| 41 | + #spip_log("autosave:$var:$val",'autosave'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - # TODO: mode lecture de session ; n'afficher que ce qu'il faut |
|
| 45 | - #echo json_encode($GLOBALS['visiteur_session']); |
|
| 44 | + # TODO: mode lecture de session ; n'afficher que ce qu'il faut |
|
| 45 | + #echo json_encode($GLOBALS['visiteur_session']); |
|
| 46 | 46 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,22 +25,22 @@ discard block |
||
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | 27 | function action_relancer_inscription_dist() { |
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $id_auteur = $securiser_action(); |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $id_auteur = $securiser_action(); |
|
| 30 | 30 | |
| 31 | - if ((int) $id_auteur && autoriser('relancer', 'inscription')) { |
|
| 32 | - $auteur = sql_fetsel('prefs, email, nom, statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 33 | - if ($auteur['statut'] == 'nouveau') { |
|
| 34 | - include_spip('action/inscrire_auteur'); |
|
| 35 | - action_inscrire_auteur_dist($auteur['prefs'], $auteur['email'], $auteur['nom'], ['force_nouveau' => true]); |
|
| 36 | - } |
|
| 37 | - } elseif ($id_auteur === '*' && autoriser('relancer', 'inscription')) { |
|
| 38 | - $auteurs = sql_allfetsel('prefs, email, nom', 'spip_auteurs', "statut='nouveau'"); |
|
| 39 | - if (is_array($auteurs)) { |
|
| 40 | - include_spip('action/inscrire_auteur'); |
|
| 41 | - while ($row = array_pop($auteurs)) { |
|
| 42 | - action_inscrire_auteur_dist($row['prefs'], $row['email'], $row['nom'], ['force_nouveau' => true]); |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - } |
|
| 31 | + if ((int) $id_auteur && autoriser('relancer', 'inscription')) { |
|
| 32 | + $auteur = sql_fetsel('prefs, email, nom, statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 33 | + if ($auteur['statut'] == 'nouveau') { |
|
| 34 | + include_spip('action/inscrire_auteur'); |
|
| 35 | + action_inscrire_auteur_dist($auteur['prefs'], $auteur['email'], $auteur['nom'], ['force_nouveau' => true]); |
|
| 36 | + } |
|
| 37 | + } elseif ($id_auteur === '*' && autoriser('relancer', 'inscription')) { |
|
| 38 | + $auteurs = sql_allfetsel('prefs, email, nom', 'spip_auteurs', "statut='nouveau'"); |
|
| 39 | + if (is_array($auteurs)) { |
|
| 40 | + include_spip('action/inscrire_auteur'); |
|
| 41 | + while ($row = array_pop($auteurs)) { |
|
| 42 | + action_inscrire_auteur_dist($row['prefs'], $row['email'], $row['nom'], ['force_nouveau' => true]); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | defined('URLS_PAGE_EXEMPLE') || define('URLS_PAGE_EXEMPLE', 'spip.php?article12'); |
@@ -29,23 +29,23 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | function urls_page_generer_url_objet_dist(int $id, string $objet, string $args = '', string $ancre = ''): string { |
| 31 | 31 | |
| 32 | - if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 33 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 34 | - // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 35 | - // une url vide est une url vide, ne rien faire de plus |
|
| 36 | - if (!is_null($url)) { |
|
| 37 | - return $url; |
|
| 38 | - } |
|
| 39 | - } |
|
| 32 | + if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) { |
|
| 33 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 34 | + // une url === null indique "je ne traite pas cette url, appliquez le calcul standard" |
|
| 35 | + // une url vide est une url vide, ne rien faire de plus |
|
| 36 | + if (!is_null($url)) { |
|
| 37 | + return $url; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 42 | - . $id . \_terminaison_urls_page; |
|
| 41 | + $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 42 | + . $id . \_terminaison_urls_page; |
|
| 43 | 43 | |
| 44 | - if ($args) { |
|
| 45 | - $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 46 | - } |
|
| 44 | + if ($args) { |
|
| 45 | + $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 48 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -61,27 +61,27 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function urls_page_decoder_url_dist(string $url, string $entite, array $contexte = []): array { |
| 63 | 63 | |
| 64 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 65 | - if ($GLOBALS['profondeur_url'] > 0 && $entite == 'sommaire') { |
|
| 66 | - return [[], '404']; |
|
| 67 | - } |
|
| 64 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 65 | + if ($GLOBALS['profondeur_url'] > 0 && $entite == 'sommaire') { |
|
| 66 | + return [[], '404']; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - include_spip('inc/urls'); |
|
| 70 | - $r = nettoyer_url_page($url, $contexte); |
|
| 71 | - if ($r) { |
|
| 72 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | - return $r; |
|
| 74 | - } |
|
| 69 | + include_spip('inc/urls'); |
|
| 70 | + $r = nettoyer_url_page($url, $contexte); |
|
| 71 | + if ($r) { |
|
| 72 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | + return $r; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /* |
|
| 76 | + /* |
|
| 77 | 77 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 78 | 78 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 79 | 79 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 80 | 80 | * et votre .htaccess |
| 81 | 81 | */ |
| 82 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | - $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 85 | - return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 86 | - /* Fin du bloc compatibilite url-propres */ |
|
| 82 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | + $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? ''; |
|
| 85 | + return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte); |
|
| 86 | + /* Fin du bloc compatibilite url-propres */ |
|
| 87 | 87 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite |
| 23 | 23 | define('_separateur_urls_page', ''); |
| 24 | 24 | # on peut indiquer '' si on a installe le .htaccess |
| 25 | -define('_debut_urls_page', get_spip_script('./') . '?'); |
|
| 25 | +define('_debut_urls_page', get_spip_script('./').'?'); |
|
| 26 | 26 | ####### |
| 27 | 27 | /** |
| 28 | 28 | * Generer l'url d'un objet SPIP |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $url = \_debut_urls_page . $objet . \_separateur_urls_page |
|
| 42 | - . $id . \_terminaison_urls_page; |
|
| 41 | + $url = \_debut_urls_page.$objet.\_separateur_urls_page |
|
| 42 | + . $id.\_terminaison_urls_page; |
|
| 43 | 43 | |
| 44 | 44 | if ($args) { |
| 45 | 45 | $args = strpos($url, '?') ? "&$args" : "?$args"; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 48 | + return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : ''); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -87,8 +87,7 @@ discard block |
||
| 87 | 87 | if (!isset($GLOBALS['db_ok'])) { |
| 88 | 88 | spip_log("spip_connect: fichier de connexion '$f' OK mais echec connexion au serveur", _LOG_HS); |
| 89 | 89 | } |
| 90 | - } |
|
| 91 | - else { |
|
| 90 | + } else { |
|
| 92 | 91 | spip_log("spip_connect: fichier de connexion '$f' non trouve, pas de connexion serveur", _LOG_HS); |
| 93 | 92 | } |
| 94 | 93 | if (!isset($GLOBALS['db_ok'])) { |
@@ -453,8 +452,7 @@ discard block |
||
| 453 | 452 | && strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
| 454 | 453 | ) { |
| 455 | 454 | $part .= array_shift($textes); |
| 456 | - } |
|
| 457 | - else { |
|
| 455 | + } else { |
|
| 458 | 456 | break; |
| 459 | 457 | } |
| 460 | 458 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | -require_once _ROOT_RESTREINT . 'base/objets.php'; |
|
| 20 | +require_once _ROOT_RESTREINT.'base/objets.php'; |
|
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | defined('_DIR_CONNECT') |
| 63 | 63 | && preg_match('/^[\w\.]*$/', $serveur) |
| 64 | 64 | ) { |
| 65 | - $f = _DIR_CONNECT . $serveur . '.php'; |
|
| 65 | + $f = _DIR_CONNECT.$serveur.'.php'; |
|
| 66 | 66 | if (!is_readable($f) && !$install) { |
| 67 | 67 | // chercher une declaration de serveur dans le path |
| 68 | 68 | // qui peut servir à des plugins à declarer des connexions à une base sqlite |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | // chargement de la version du jeu de fonctions |
| 111 | 111 | // si pas dans le fichier par defaut |
| 112 | 112 | $type = $GLOBALS['db_ok']['type']; |
| 113 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 114 | - if (!isset($GLOBALS[$jeu]) && !find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 113 | + $jeu = 'spip_'.$type.'_functions_'.$version; |
|
| 114 | + if (!isset($GLOBALS[$jeu]) && !find_in_path($type.'_'.$version.'.php', 'req/', true)) { |
|
| 115 | 115 | spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
| 116 | 116 | // ne plus reessayer |
| 117 | 117 | return $GLOBALS['connexions'][$index][$version] = []; |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | $connexion = spip_connect($serveur); |
| 172 | 172 | $e = sql_errno($serveur); |
| 173 | 173 | $t = ($connexion['type'] ?? 'sql'); |
| 174 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim((string) $connexion['last']); |
|
| 175 | - $f = $t . $serveur; |
|
| 176 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 174 | + $m = "Erreur $e de $t: ".sql_error($serveur)."\nin ".sql_error_backtrace()."\n".trim((string) $connexion['last']); |
|
| 175 | + $f = $t.$serveur; |
|
| 176 | + spip_log($m, $f.'.'._LOG_ERREUR); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | // si en cours d'installation ou si db=@test@ on ne pose rien |
| 260 | 260 | // car c'est un test de connexion |
| 261 | 261 | if (!defined('_ECRIRE_INSTALL') && $db !== '@test@') { |
| 262 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 262 | + $f = _DIR_TMP.$type.'.'.substr(md5($host.$port.$db), 0, 8).'.out'; |
|
| 263 | 263 | } elseif ($db == '@test@') { |
| 264 | 264 | $db = ''; |
| 265 | 265 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | // En cas d'indisponibilite du serveur, eviter de le bombarder |
| 299 | 299 | if ($f) { |
| 300 | 300 | @touch($f); |
| 301 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 301 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type.'.'._LOG_HS); |
|
| 302 | 302 | } |
| 303 | 303 | return null; |
| 304 | 304 | } |
@@ -395,11 +395,11 @@ discard block |
||
| 395 | 395 | } elseif (is_array($a)) { |
| 396 | 396 | return implode(',', array_map('_q', $a)); |
| 397 | 397 | } elseif (is_scalar($a)) { |
| 398 | - return ("'" . addslashes($a) . "'"); |
|
| 398 | + return ("'".addslashes($a)."'"); |
|
| 399 | 399 | } elseif ($a === null) { |
| 400 | 400 | return "''"; |
| 401 | 401 | } |
| 402 | - throw new \RuntimeException('Can’t use _q with ' . gettype($a)); |
|
| 402 | + throw new \RuntimeException('Can’t use _q with '.gettype($a)); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | $next = reset($textes); |
| 451 | 451 | if ( |
| 452 | 452 | str_starts_with((string) $next, "'") |
| 453 | - && strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
|
| 453 | + && strpos($query_echappees, $part.$next, $currentpos) === $nextpos |
|
| 454 | 454 | ) { |
| 455 | 455 | $part .= array_shift($textes); |
| 456 | 456 | } |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | $parts[$k] = [ |
| 463 | 463 | 'texte' => $part, |
| 464 | 464 | 'position' => $nextpos, |
| 465 | - 'placeholder' => '%' . $k . '$s', |
|
| 465 | + 'placeholder' => '%'.$k.'$s', |
|
| 466 | 466 | ]; |
| 467 | 467 | $currentpos = $nextpos + strlen((string) $part); |
| 468 | 468 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\SQL |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | require_once _ROOT_RESTREINT . 'base/objets.php'; |
| 21 | 21 | |
@@ -41,125 +41,125 @@ discard block |
||
| 41 | 41 | **/ |
| 42 | 42 | function spip_connect($serveur = '', $version = '') { |
| 43 | 43 | |
| 44 | - $serveur = is_string($serveur) ? strtolower($serveur) : ''; |
|
| 45 | - $index = $serveur ?: 0; |
|
| 46 | - if (!$version) { |
|
| 47 | - $version = $GLOBALS['spip_sql_version']; |
|
| 48 | - } |
|
| 49 | - if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 50 | - return $GLOBALS['connexions'][$index]; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - include_spip('base/abstract_sql'); |
|
| 54 | - $install = (_request('exec') == 'install'); |
|
| 55 | - |
|
| 56 | - // Premiere connexion ? |
|
| 57 | - if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 58 | - $f = ''; |
|
| 59 | - if ($serveur) { |
|
| 60 | - // serveur externe et nom de serveur bien ecrit ? |
|
| 61 | - if ( |
|
| 62 | - defined('_DIR_CONNECT') |
|
| 63 | - && preg_match('/^[\w\.]*$/', $serveur) |
|
| 64 | - ) { |
|
| 65 | - $f = _DIR_CONNECT . $serveur . '.php'; |
|
| 66 | - if (!is_readable($f) && !$install) { |
|
| 67 | - // chercher une declaration de serveur dans le path |
|
| 68 | - // qui peut servir à des plugins à declarer des connexions à une base sqlite |
|
| 69 | - // Ex: sert aux boucles POUR et au plugin-dist dump pour se connecter sur le sqlite du dump |
|
| 70 | - $f = find_in_path("$serveur.php", 'connect/'); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } else { |
|
| 74 | - if (defined('_FILE_CONNECT') && _FILE_CONNECT) { |
|
| 75 | - // init du serveur principal |
|
| 76 | - $f = _FILE_CONNECT; |
|
| 77 | - } elseif ($install && defined('_FILE_CONNECT_TMP')) { |
|
| 78 | - // installation en cours |
|
| 79 | - $f = _FILE_CONNECT_TMP; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - unset($GLOBALS['db_ok']); |
|
| 84 | - unset($GLOBALS['spip_connect_version']); |
|
| 85 | - if ($f && is_readable($f)) { |
|
| 86 | - include($f); |
|
| 87 | - if (!isset($GLOBALS['db_ok'])) { |
|
| 88 | - spip_log("spip_connect: fichier de connexion '$f' OK mais echec connexion au serveur", _LOG_HS); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - else { |
|
| 92 | - spip_log("spip_connect: fichier de connexion '$f' non trouve, pas de connexion serveur", _LOG_HS); |
|
| 93 | - } |
|
| 94 | - if (!isset($GLOBALS['db_ok'])) { |
|
| 95 | - // fera mieux la prochaine fois |
|
| 96 | - if ($install) { |
|
| 97 | - return false; |
|
| 98 | - } |
|
| 99 | - // ne plus reessayer si ce n'est pas l'install |
|
| 100 | - return $GLOBALS['connexions'][$index] = false; |
|
| 101 | - } |
|
| 102 | - $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 103 | - } |
|
| 104 | - // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 105 | - if (!$GLOBALS['connexions'][$index]) { |
|
| 106 | - return false; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // la connexion a reussi ou etait deja faite. |
|
| 110 | - // chargement de la version du jeu de fonctions |
|
| 111 | - // si pas dans le fichier par defaut |
|
| 112 | - $type = $GLOBALS['db_ok']['type']; |
|
| 113 | - $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 114 | - if (!isset($GLOBALS[$jeu]) && !find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 115 | - spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 116 | - // ne plus reessayer |
|
| 117 | - return $GLOBALS['connexions'][$index][$version] = []; |
|
| 118 | - } |
|
| 119 | - $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 120 | - if ($old) { |
|
| 121 | - return $GLOBALS['connexions'][$index]; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - $GLOBALS['connexions'][$index]['spip_connect_version'] = $GLOBALS['spip_connect_version'] ?? 0; |
|
| 125 | - |
|
| 126 | - // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 127 | - // si l'installation l'a determine. |
|
| 128 | - // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 129 | - // s'ils le connaissent |
|
| 130 | - |
|
| 131 | - if (!$serveur) { |
|
| 132 | - $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 133 | - if (!$charset) { |
|
| 134 | - unset($GLOBALS['connexions'][$index]); |
|
| 135 | - spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 136 | - |
|
| 137 | - return false; |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - if ($GLOBALS['db_ok']['charset']) { |
|
| 141 | - $charset = $GLOBALS['db_ok']['charset']; |
|
| 142 | - } |
|
| 143 | - // spip_meta n'existe pas toujours dans la base |
|
| 144 | - // C'est le cas d'un dump sqlite par exemple |
|
| 145 | - elseif ( |
|
| 146 | - $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 147 | - && sql_showtable('spip_meta', true, $serveur) |
|
| 148 | - && ($r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur)) |
|
| 149 | - ) { |
|
| 150 | - $charset = $r; |
|
| 151 | - } else { |
|
| 152 | - $charset = -1; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - if ($charset != -1) { |
|
| 156 | - $f = $GLOBALS[$jeu]['set_charset']; |
|
| 157 | - if (function_exists($f)) { |
|
| 158 | - $f($charset, $serveur); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - return $GLOBALS['connexions'][$index]; |
|
| 44 | + $serveur = is_string($serveur) ? strtolower($serveur) : ''; |
|
| 45 | + $index = $serveur ?: 0; |
|
| 46 | + if (!$version) { |
|
| 47 | + $version = $GLOBALS['spip_sql_version']; |
|
| 48 | + } |
|
| 49 | + if (isset($GLOBALS['connexions'][$index][$version])) { |
|
| 50 | + return $GLOBALS['connexions'][$index]; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + include_spip('base/abstract_sql'); |
|
| 54 | + $install = (_request('exec') == 'install'); |
|
| 55 | + |
|
| 56 | + // Premiere connexion ? |
|
| 57 | + if (!($old = isset($GLOBALS['connexions'][$index]))) { |
|
| 58 | + $f = ''; |
|
| 59 | + if ($serveur) { |
|
| 60 | + // serveur externe et nom de serveur bien ecrit ? |
|
| 61 | + if ( |
|
| 62 | + defined('_DIR_CONNECT') |
|
| 63 | + && preg_match('/^[\w\.]*$/', $serveur) |
|
| 64 | + ) { |
|
| 65 | + $f = _DIR_CONNECT . $serveur . '.php'; |
|
| 66 | + if (!is_readable($f) && !$install) { |
|
| 67 | + // chercher une declaration de serveur dans le path |
|
| 68 | + // qui peut servir à des plugins à declarer des connexions à une base sqlite |
|
| 69 | + // Ex: sert aux boucles POUR et au plugin-dist dump pour se connecter sur le sqlite du dump |
|
| 70 | + $f = find_in_path("$serveur.php", 'connect/'); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } else { |
|
| 74 | + if (defined('_FILE_CONNECT') && _FILE_CONNECT) { |
|
| 75 | + // init du serveur principal |
|
| 76 | + $f = _FILE_CONNECT; |
|
| 77 | + } elseif ($install && defined('_FILE_CONNECT_TMP')) { |
|
| 78 | + // installation en cours |
|
| 79 | + $f = _FILE_CONNECT_TMP; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + unset($GLOBALS['db_ok']); |
|
| 84 | + unset($GLOBALS['spip_connect_version']); |
|
| 85 | + if ($f && is_readable($f)) { |
|
| 86 | + include($f); |
|
| 87 | + if (!isset($GLOBALS['db_ok'])) { |
|
| 88 | + spip_log("spip_connect: fichier de connexion '$f' OK mais echec connexion au serveur", _LOG_HS); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + else { |
|
| 92 | + spip_log("spip_connect: fichier de connexion '$f' non trouve, pas de connexion serveur", _LOG_HS); |
|
| 93 | + } |
|
| 94 | + if (!isset($GLOBALS['db_ok'])) { |
|
| 95 | + // fera mieux la prochaine fois |
|
| 96 | + if ($install) { |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 99 | + // ne plus reessayer si ce n'est pas l'install |
|
| 100 | + return $GLOBALS['connexions'][$index] = false; |
|
| 101 | + } |
|
| 102 | + $GLOBALS['connexions'][$index] = $GLOBALS['db_ok']; |
|
| 103 | + } |
|
| 104 | + // si la connexion a deja ete tentee mais a echoue, le dire! |
|
| 105 | + if (!$GLOBALS['connexions'][$index]) { |
|
| 106 | + return false; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // la connexion a reussi ou etait deja faite. |
|
| 110 | + // chargement de la version du jeu de fonctions |
|
| 111 | + // si pas dans le fichier par defaut |
|
| 112 | + $type = $GLOBALS['db_ok']['type']; |
|
| 113 | + $jeu = 'spip_' . $type . '_functions_' . $version; |
|
| 114 | + if (!isset($GLOBALS[$jeu]) && !find_in_path($type . '_' . $version . '.php', 'req/', true)) { |
|
| 115 | + spip_log("spip_connect: serveur $index version '$version' non defini pour '$type'", _LOG_HS); |
|
| 116 | + // ne plus reessayer |
|
| 117 | + return $GLOBALS['connexions'][$index][$version] = []; |
|
| 118 | + } |
|
| 119 | + $GLOBALS['connexions'][$index][$version] = $GLOBALS[$jeu]; |
|
| 120 | + if ($old) { |
|
| 121 | + return $GLOBALS['connexions'][$index]; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + $GLOBALS['connexions'][$index]['spip_connect_version'] = $GLOBALS['spip_connect_version'] ?? 0; |
|
| 125 | + |
|
| 126 | + // initialisation de l'alphabet utilise dans les connexions SQL |
|
| 127 | + // si l'installation l'a determine. |
|
| 128 | + // Celui du serveur principal l'impose aux serveurs secondaires |
|
| 129 | + // s'ils le connaissent |
|
| 130 | + |
|
| 131 | + if (!$serveur) { |
|
| 132 | + $charset = spip_connect_main($GLOBALS[$jeu], $GLOBALS['db_ok']['charset']); |
|
| 133 | + if (!$charset) { |
|
| 134 | + unset($GLOBALS['connexions'][$index]); |
|
| 135 | + spip_log('spip_connect: absence de charset', _LOG_AVERTISSEMENT); |
|
| 136 | + |
|
| 137 | + return false; |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + if ($GLOBALS['db_ok']['charset']) { |
|
| 141 | + $charset = $GLOBALS['db_ok']['charset']; |
|
| 142 | + } |
|
| 143 | + // spip_meta n'existe pas toujours dans la base |
|
| 144 | + // C'est le cas d'un dump sqlite par exemple |
|
| 145 | + elseif ( |
|
| 146 | + $GLOBALS['connexions'][$index]['spip_connect_version'] |
|
| 147 | + && sql_showtable('spip_meta', true, $serveur) |
|
| 148 | + && ($r = sql_getfetsel('valeur', 'spip_meta', "nom='charset_sql_connexion'", '', '', '', '', $serveur)) |
|
| 149 | + ) { |
|
| 150 | + $charset = $r; |
|
| 151 | + } else { |
|
| 152 | + $charset = -1; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + if ($charset != -1) { |
|
| 156 | + $f = $GLOBALS[$jeu]['set_charset']; |
|
| 157 | + if (function_exists($f)) { |
|
| 158 | + $f($charset, $serveur); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + return $GLOBALS['connexions'][$index]; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | * @param string $serveur Nom du connecteur de bdd utilisé |
| 169 | 169 | **/ |
| 170 | 170 | function spip_sql_erreur($serveur = '') { |
| 171 | - $connexion = spip_connect($serveur); |
|
| 172 | - $e = sql_errno($serveur); |
|
| 173 | - $t = ($connexion['type'] ?? 'sql'); |
|
| 174 | - $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim((string) $connexion['last']); |
|
| 175 | - $f = $t . $serveur; |
|
| 176 | - spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 171 | + $connexion = spip_connect($serveur); |
|
| 172 | + $e = sql_errno($serveur); |
|
| 173 | + $t = ($connexion['type'] ?? 'sql'); |
|
| 174 | + $m = "Erreur $e de $t: " . sql_error($serveur) . "\nin " . sql_error_backtrace() . "\n" . trim((string) $connexion['last']); |
|
| 175 | + $f = $t . $serveur; |
|
| 176 | + spip_log($m, $f . '.' . _LOG_ERREUR); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -195,23 +195,23 @@ discard block |
||
| 195 | 195 | * - array : description de la connexion, si l'instruction sql est indisponible pour cette connexion |
| 196 | 196 | **/ |
| 197 | 197 | function spip_connect_sql($version, $ins = '', $serveur = '', $continue = false) { |
| 198 | - $desc = spip_connect($serveur, $version); |
|
| 199 | - if ( |
|
| 200 | - $desc |
|
| 201 | - && ($f = ($desc[$version][$ins] ?? '')) |
|
| 202 | - && function_exists($f) |
|
| 203 | - ) { |
|
| 204 | - return $f; |
|
| 205 | - } |
|
| 206 | - if ($continue) { |
|
| 207 | - return $desc; |
|
| 208 | - } |
|
| 209 | - if ($ins) { |
|
| 210 | - spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 211 | - } |
|
| 212 | - include_spip('inc/minipres'); |
|
| 213 | - echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 214 | - exit; |
|
| 198 | + $desc = spip_connect($serveur, $version); |
|
| 199 | + if ( |
|
| 200 | + $desc |
|
| 201 | + && ($f = ($desc[$version][$ins] ?? '')) |
|
| 202 | + && function_exists($f) |
|
| 203 | + ) { |
|
| 204 | + return $f; |
|
| 205 | + } |
|
| 206 | + if ($continue) { |
|
| 207 | + return $desc; |
|
| 208 | + } |
|
| 209 | + if ($ins) { |
|
| 210 | + spip_log("Le serveur '$serveur' version $version n'a pas '$ins'", _LOG_ERREUR); |
|
| 211 | + } |
|
| 212 | + include_spip('inc/minipres'); |
|
| 213 | + echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), ['status' => 503]); |
|
| 214 | + exit; |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
@@ -237,70 +237,70 @@ discard block |
||
| 237 | 237 | * @return array|null Description de la connexion |
| 238 | 238 | */ |
| 239 | 239 | function spip_connect_db( |
| 240 | - $host, |
|
| 241 | - $port, |
|
| 242 | - $login, |
|
| 243 | - #[\SensitiveParameter] $pass, |
|
| 244 | - $db = '', |
|
| 245 | - $type = 'mysql', |
|
| 246 | - $prefixe = '', |
|
| 247 | - $auth = '', |
|
| 248 | - $charset = '' |
|
| 240 | + $host, |
|
| 241 | + $port, |
|
| 242 | + $login, |
|
| 243 | + #[\SensitiveParameter] $pass, |
|
| 244 | + $db = '', |
|
| 245 | + $type = 'mysql', |
|
| 246 | + $prefixe = '', |
|
| 247 | + $auth = '', |
|
| 248 | + $charset = '' |
|
| 249 | 249 | ) { |
| 250 | - // temps avant nouvelle tentative de connexion |
|
| 251 | - // suite a une connection echouee |
|
| 252 | - if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 253 | - define('_CONNECT_RETRY_DELAY', 30); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - $f = ''; |
|
| 257 | - // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 258 | - // pour ne pas declarer tout indisponible d'un coup |
|
| 259 | - // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 260 | - // car c'est un test de connexion |
|
| 261 | - if (!defined('_ECRIRE_INSTALL') && $db !== '@test@') { |
|
| 262 | - $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 263 | - } elseif ($db == '@test@') { |
|
| 264 | - $db = ''; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if ( |
|
| 268 | - $f |
|
| 269 | - && @file_exists($f) |
|
| 270 | - && (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 271 | - ) { |
|
| 272 | - spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 273 | - |
|
| 274 | - return null; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - if (!$prefixe) { |
|
| 278 | - $prefixe = $GLOBALS['table_prefix'] ?? $db; |
|
| 279 | - } |
|
| 280 | - $h = charger_fonction($type, 'req', true); |
|
| 281 | - if (!$h) { |
|
| 282 | - spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 283 | - |
|
| 284 | - return null; |
|
| 285 | - } |
|
| 286 | - if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 287 | - if (!is_array($auth)) { |
|
| 288 | - // compatibilite version 0.7 initiale |
|
| 289 | - $g['ldap'] = $auth; |
|
| 290 | - $auth = ['ldap' => $auth]; |
|
| 291 | - } |
|
| 292 | - $g['authentification'] = $auth; |
|
| 293 | - $g['type'] = $type; |
|
| 294 | - $g['charset'] = $charset; |
|
| 295 | - |
|
| 296 | - return $GLOBALS['db_ok'] = $g; |
|
| 297 | - } |
|
| 298 | - // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 299 | - if ($f) { |
|
| 300 | - @touch($f); |
|
| 301 | - spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 302 | - } |
|
| 303 | - return null; |
|
| 250 | + // temps avant nouvelle tentative de connexion |
|
| 251 | + // suite a une connection echouee |
|
| 252 | + if (!defined('_CONNECT_RETRY_DELAY')) { |
|
| 253 | + define('_CONNECT_RETRY_DELAY', 30); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + $f = ''; |
|
| 257 | + // un fichier de identifiant par combinaison (type,host,port,db) |
|
| 258 | + // pour ne pas declarer tout indisponible d'un coup |
|
| 259 | + // si en cours d'installation ou si db=@test@ on ne pose rien |
|
| 260 | + // car c'est un test de connexion |
|
| 261 | + if (!defined('_ECRIRE_INSTALL') && $db !== '@test@') { |
|
| 262 | + $f = _DIR_TMP . $type . '.' . substr(md5($host . $port . $db), 0, 8) . '.out'; |
|
| 263 | + } elseif ($db == '@test@') { |
|
| 264 | + $db = ''; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if ( |
|
| 268 | + $f |
|
| 269 | + && @file_exists($f) |
|
| 270 | + && (time() - @filemtime($f) < _CONNECT_RETRY_DELAY) |
|
| 271 | + ) { |
|
| 272 | + spip_log("Echec : $f recent. Pas de tentative de connexion", _LOG_HS); |
|
| 273 | + |
|
| 274 | + return null; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + if (!$prefixe) { |
|
| 278 | + $prefixe = $GLOBALS['table_prefix'] ?? $db; |
|
| 279 | + } |
|
| 280 | + $h = charger_fonction($type, 'req', true); |
|
| 281 | + if (!$h) { |
|
| 282 | + spip_log("les requetes $type ne sont pas fournies", _LOG_HS); |
|
| 283 | + |
|
| 284 | + return null; |
|
| 285 | + } |
|
| 286 | + if ($g = $h($host, $port, $login, $pass, $db, $prefixe)) { |
|
| 287 | + if (!is_array($auth)) { |
|
| 288 | + // compatibilite version 0.7 initiale |
|
| 289 | + $g['ldap'] = $auth; |
|
| 290 | + $auth = ['ldap' => $auth]; |
|
| 291 | + } |
|
| 292 | + $g['authentification'] = $auth; |
|
| 293 | + $g['type'] = $type; |
|
| 294 | + $g['charset'] = $charset; |
|
| 295 | + |
|
| 296 | + return $GLOBALS['db_ok'] = $g; |
|
| 297 | + } |
|
| 298 | + // En cas d'indisponibilite du serveur, eviter de le bombarder |
|
| 299 | + if ($f) { |
|
| 300 | + @touch($f); |
|
| 301 | + spip_log("Echec connexion serveur $type : host[$host] port[$port] login[$login] base[$db]", $type . '.' . _LOG_HS); |
|
| 302 | + } |
|
| 303 | + return null; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | |
@@ -332,32 +332,32 @@ discard block |
||
| 332 | 332 | * - nom du charset sinon |
| 333 | 333 | **/ |
| 334 | 334 | function spip_connect_main($connexion, $charset_sql_connexion = '') { |
| 335 | - if ($GLOBALS['spip_connect_version'] < 0.1 && _DIR_RESTREINT) { |
|
| 336 | - include_spip('inc/headers'); |
|
| 337 | - redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - if (!($f = $connexion['select'])) { |
|
| 341 | - return false; |
|
| 342 | - } |
|
| 343 | - // si le charset est fourni, l'utiliser |
|
| 344 | - if ($charset_sql_connexion) { |
|
| 345 | - return $charset_sql_connexion; |
|
| 346 | - } |
|
| 347 | - // sinon on regarde la table spip_meta |
|
| 348 | - // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 349 | - if ( |
|
| 350 | - !($r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'")) |
|
| 351 | - || is_string($r) |
|
| 352 | - ) { |
|
| 353 | - return false; |
|
| 354 | - } |
|
| 355 | - if (!($f = $connexion['fetch'])) { |
|
| 356 | - return false; |
|
| 357 | - } |
|
| 358 | - $r = $f($r); |
|
| 359 | - |
|
| 360 | - return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 335 | + if ($GLOBALS['spip_connect_version'] < 0.1 && _DIR_RESTREINT) { |
|
| 336 | + include_spip('inc/headers'); |
|
| 337 | + redirige_url_ecrire('upgrade', 'reinstall=oui'); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + if (!($f = $connexion['select'])) { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + // si le charset est fourni, l'utiliser |
|
| 344 | + if ($charset_sql_connexion) { |
|
| 345 | + return $charset_sql_connexion; |
|
| 346 | + } |
|
| 347 | + // sinon on regarde la table spip_meta |
|
| 348 | + // en cas d'erreur select retourne la requette (is_string=true donc) |
|
| 349 | + if ( |
|
| 350 | + !($r = $f('valeur', 'spip_meta', "nom='charset_sql_connexion'")) |
|
| 351 | + || is_string($r) |
|
| 352 | + ) { |
|
| 353 | + return false; |
|
| 354 | + } |
|
| 355 | + if (!($f = $connexion['fetch'])) { |
|
| 356 | + return false; |
|
| 357 | + } |
|
| 358 | + $r = $f($r); |
|
| 359 | + |
|
| 360 | + return (isset($r['valeur']) && $r['valeur']) ? $r['valeur'] : -1; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -373,16 +373,16 @@ discard block |
||
| 373 | 373 | * @return string Valeur échappée. |
| 374 | 374 | **/ |
| 375 | 375 | function _q($a): string { |
| 376 | - if (is_numeric($a)) { |
|
| 377 | - return (string) $a; |
|
| 378 | - } elseif (is_array($a)) { |
|
| 379 | - return implode(',', array_map('_q', $a)); |
|
| 380 | - } elseif (is_scalar($a)) { |
|
| 381 | - return ("'" . addslashes($a) . "'"); |
|
| 382 | - } elseif ($a === null) { |
|
| 383 | - return "''"; |
|
| 384 | - } |
|
| 385 | - throw new \RuntimeException('Can’t use _q with ' . gettype($a)); |
|
| 376 | + if (is_numeric($a)) { |
|
| 377 | + return (string) $a; |
|
| 378 | + } elseif (is_array($a)) { |
|
| 379 | + return implode(',', array_map('_q', $a)); |
|
| 380 | + } elseif (is_scalar($a)) { |
|
| 381 | + return ("'" . addslashes($a) . "'"); |
|
| 382 | + } elseif ($a === null) { |
|
| 383 | + return "''"; |
|
| 384 | + } |
|
| 385 | + throw new \RuntimeException('Can’t use _q with ' . gettype($a)); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -398,75 +398,75 @@ discard block |
||
| 398 | 398 | * @return array |
| 399 | 399 | */ |
| 400 | 400 | function query_echappe_textes($query, $uniqid = null) { |
| 401 | - static $codeEchappements = null; |
|
| 402 | - if (is_null($codeEchappements) || $uniqid) { |
|
| 403 | - if (is_null($uniqid)) { |
|
| 404 | - $uniqid = uniqid(); |
|
| 405 | - } |
|
| 406 | - $uniqid = substr(md5((string) $uniqid), 0, 4); |
|
| 407 | - $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3", '%' => "\x4@#{$uniqid}#@\x4"]; |
|
| 408 | - } |
|
| 409 | - if ($query === null) { |
|
| 410 | - return $codeEchappements; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 414 | - // ce n'est pas un cas legitime |
|
| 415 | - foreach ($codeEchappements as $codeEchappement) { |
|
| 416 | - if (str_contains($query, (string) $codeEchappement)) { |
|
| 417 | - return [$query, []]; |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 422 | - if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 423 | - $textes = reset($textes); |
|
| 424 | - |
|
| 425 | - $parts = []; |
|
| 426 | - $currentpos = 0; |
|
| 427 | - $k = 0; |
|
| 428 | - while (count($textes)) { |
|
| 429 | - $part = array_shift($textes); |
|
| 430 | - $nextpos = strpos($query_echappees, (string) $part, $currentpos); |
|
| 431 | - // si besoin recoller ensemble les doubles '' de sqlite (echappement des ') |
|
| 432 | - while (count($textes) && str_ends_with((string) $part, "'")) { |
|
| 433 | - $next = reset($textes); |
|
| 434 | - if ( |
|
| 435 | - str_starts_with((string) $next, "'") |
|
| 436 | - && strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
|
| 437 | - ) { |
|
| 438 | - $part .= array_shift($textes); |
|
| 439 | - } |
|
| 440 | - else { |
|
| 441 | - break; |
|
| 442 | - } |
|
| 443 | - } |
|
| 444 | - $k++; |
|
| 445 | - $parts[$k] = [ |
|
| 446 | - 'texte' => $part, |
|
| 447 | - 'position' => $nextpos, |
|
| 448 | - 'placeholder' => '%' . $k . '$s', |
|
| 449 | - ]; |
|
| 450 | - $currentpos = $nextpos + strlen((string) $part); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - // et on replace les parts une par une en commencant par la fin |
|
| 454 | - while ($k > 0) { |
|
| 455 | - $query_echappees = substr_replace($query_echappees, $parts[$k]['placeholder'], $parts[$k]['position'], strlen((string) $parts[$k]['texte'])); |
|
| 456 | - $k--; |
|
| 457 | - } |
|
| 458 | - $textes = array_column($parts, 'texte'); |
|
| 459 | - } else { |
|
| 460 | - $textes = []; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelle les pinceaux |
|
| 464 | - // dans le doute on ne touche a rien |
|
| 465 | - if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 466 | - return [$query, []]; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - return [$query_echappees, $textes]; |
|
| 401 | + static $codeEchappements = null; |
|
| 402 | + if (is_null($codeEchappements) || $uniqid) { |
|
| 403 | + if (is_null($uniqid)) { |
|
| 404 | + $uniqid = uniqid(); |
|
| 405 | + } |
|
| 406 | + $uniqid = substr(md5((string) $uniqid), 0, 4); |
|
| 407 | + $codeEchappements = ['\\\\' => "\x1@#{$uniqid}#@\x1", "\\'" => "\x2@#{$uniqid}#@\x2", '\\"' => "\x3@#{$uniqid}#@\x3", '%' => "\x4@#{$uniqid}#@\x4"]; |
|
| 408 | + } |
|
| 409 | + if ($query === null) { |
|
| 410 | + return $codeEchappements; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + // si la query contient deja des codes d'echappement on va s'emmeler les pinceaux et donc on ne touche a rien |
|
| 414 | + // ce n'est pas un cas legitime |
|
| 415 | + foreach ($codeEchappements as $codeEchappement) { |
|
| 416 | + if (str_contains($query, (string) $codeEchappement)) { |
|
| 417 | + return [$query, []]; |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + $query_echappees = str_replace(array_keys($codeEchappements), array_values($codeEchappements), $query); |
|
| 422 | + if (preg_match_all("/('[^']*')|(\"[^\"]*\")/S", $query_echappees, $textes)) { |
|
| 423 | + $textes = reset($textes); |
|
| 424 | + |
|
| 425 | + $parts = []; |
|
| 426 | + $currentpos = 0; |
|
| 427 | + $k = 0; |
|
| 428 | + while (count($textes)) { |
|
| 429 | + $part = array_shift($textes); |
|
| 430 | + $nextpos = strpos($query_echappees, (string) $part, $currentpos); |
|
| 431 | + // si besoin recoller ensemble les doubles '' de sqlite (echappement des ') |
|
| 432 | + while (count($textes) && str_ends_with((string) $part, "'")) { |
|
| 433 | + $next = reset($textes); |
|
| 434 | + if ( |
|
| 435 | + str_starts_with((string) $next, "'") |
|
| 436 | + && strpos($query_echappees, $part . $next, $currentpos) === $nextpos |
|
| 437 | + ) { |
|
| 438 | + $part .= array_shift($textes); |
|
| 439 | + } |
|
| 440 | + else { |
|
| 441 | + break; |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | + $k++; |
|
| 445 | + $parts[$k] = [ |
|
| 446 | + 'texte' => $part, |
|
| 447 | + 'position' => $nextpos, |
|
| 448 | + 'placeholder' => '%' . $k . '$s', |
|
| 449 | + ]; |
|
| 450 | + $currentpos = $nextpos + strlen((string) $part); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + // et on replace les parts une par une en commencant par la fin |
|
| 454 | + while ($k > 0) { |
|
| 455 | + $query_echappees = substr_replace($query_echappees, $parts[$k]['placeholder'], $parts[$k]['position'], strlen((string) $parts[$k]['texte'])); |
|
| 456 | + $k--; |
|
| 457 | + } |
|
| 458 | + $textes = array_column($parts, 'texte'); |
|
| 459 | + } else { |
|
| 460 | + $textes = []; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + // si il reste des quotes simples ou doubles, c'est qu'on s'est emmelle les pinceaux |
|
| 464 | + // dans le doute on ne touche a rien |
|
| 465 | + if (strpbrk($query_echappees, "'\"") !== false) { |
|
| 466 | + return [$query, []]; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + return [$query_echappees, $textes]; |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | /** |
@@ -480,14 +480,14 @@ discard block |
||
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | 482 | function query_reinjecte_textes($query, $textes) { |
| 483 | - // recuperer les codes echappements |
|
| 484 | - $codeEchappements = query_echappe_textes(null); |
|
| 483 | + // recuperer les codes echappements |
|
| 484 | + $codeEchappements = query_echappe_textes(null); |
|
| 485 | 485 | |
| 486 | - if (!empty($textes)) { |
|
| 487 | - $query = sprintf($query, ...$textes); |
|
| 488 | - } |
|
| 486 | + if (!empty($textes)) { |
|
| 487 | + $query = sprintf($query, ...$textes); |
|
| 488 | + } |
|
| 489 | 489 | |
| 490 | - return str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 490 | + return str_replace(array_values($codeEchappements), array_keys($codeEchappements), $query); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | **/ |
| 507 | 507 | function spip_query($query, $serveur = '') { |
| 508 | 508 | |
| 509 | - $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 509 | + $f = spip_connect_sql($GLOBALS['spip_sql_version'], 'query', $serveur, true); |
|
| 510 | 510 | |
| 511 | - return function_exists($f) ? $f($query, $serveur) : false; |
|
| 511 | + return function_exists($f) ? $f($query, $serveur) : false; |
|
| 512 | 512 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -48,38 +48,38 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | function balise_ID_LOGO__dist($p) { |
| 50 | 50 | |
| 51 | - preg_match(',^ID_LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 52 | - $type = strtolower($regs[1]); |
|
| 53 | - $suite_logo = $regs[2]; |
|
| 54 | - |
|
| 55 | - // cas de #ID_LOGO_SITE_SPIP |
|
| 56 | - if ($type == 'site_spip') { |
|
| 57 | - $type = 'site'; |
|
| 58 | - $_id_objet = "\"'0'\""; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - $id_objet = id_table_objet($type); |
|
| 62 | - if (!isset($_id_objet)) { |
|
| 63 | - $_id_objet = champ_sql($id_objet, $p); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 67 | - if ($type == 'document') { |
|
| 68 | - $qconnect = _q($connect); |
|
| 69 | - $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 70 | - $code = "table_valeur($doc, 'id_vignette')"; |
|
| 71 | - } elseif ($connect) { |
|
| 72 | - $code = "''"; |
|
| 73 | - spip_log('Les logos distants ne sont pas prevus'); |
|
| 74 | - } else { |
|
| 75 | - $champ_logo = 'id'; |
|
| 76 | - $code = generer_code_logo($id_objet, $_id_objet, $type, '', "''", $p, $suite_logo, $champ_logo); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $p->code = $code; |
|
| 80 | - $p->interdire_scripts = false; |
|
| 81 | - |
|
| 82 | - return $p; |
|
| 51 | + preg_match(',^ID_LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 52 | + $type = strtolower($regs[1]); |
|
| 53 | + $suite_logo = $regs[2]; |
|
| 54 | + |
|
| 55 | + // cas de #ID_LOGO_SITE_SPIP |
|
| 56 | + if ($type == 'site_spip') { |
|
| 57 | + $type = 'site'; |
|
| 58 | + $_id_objet = "\"'0'\""; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + $id_objet = id_table_objet($type); |
|
| 62 | + if (!isset($_id_objet)) { |
|
| 63 | + $_id_objet = champ_sql($id_objet, $p); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 67 | + if ($type == 'document') { |
|
| 68 | + $qconnect = _q($connect); |
|
| 69 | + $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 70 | + $code = "table_valeur($doc, 'id_vignette')"; |
|
| 71 | + } elseif ($connect) { |
|
| 72 | + $code = "''"; |
|
| 73 | + spip_log('Les logos distants ne sont pas prevus'); |
|
| 74 | + } else { |
|
| 75 | + $champ_logo = 'id'; |
|
| 76 | + $code = generer_code_logo($id_objet, $_id_objet, $type, '', "''", $p, $suite_logo, $champ_logo); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $p->code = $code; |
|
| 80 | + $p->interdire_scripts = false; |
|
| 81 | + |
|
| 82 | + return $p; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
@@ -108,28 +108,28 @@ discard block |
||
| 108 | 108 | * Code compilé retournant le chemin du logo ou le code HTML du logo. |
| 109 | 109 | **/ |
| 110 | 110 | function generer_code_logo($id_objet, $_id_objet, $type, $align, $_lien, $p, $suite, string $champ = ''): string { |
| 111 | - $onoff = 'ON'; |
|
| 112 | - $_id_rubrique = "''"; |
|
| 111 | + $onoff = 'ON'; |
|
| 112 | + $_id_rubrique = "''"; |
|
| 113 | 113 | |
| 114 | - if ($type === 'rubrique') { |
|
| 115 | - $_id_rubrique = "quete_parent($_id_objet)"; |
|
| 116 | - } |
|
| 114 | + if ($type === 'rubrique') { |
|
| 115 | + $_id_rubrique = "quete_parent($_id_objet)"; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - if ($suite === '_SURVOL') { |
|
| 119 | - $onoff = 'off'; |
|
| 120 | - } elseif ($suite === '_NORMAL') { |
|
| 121 | - $onoff = 'on'; |
|
| 122 | - } elseif ($suite === '_RUBRIQUE') { |
|
| 123 | - $_id_rubrique = champ_sql('id_rubrique', $p); |
|
| 124 | - } |
|
| 118 | + if ($suite === '_SURVOL') { |
|
| 119 | + $onoff = 'off'; |
|
| 120 | + } elseif ($suite === '_NORMAL') { |
|
| 121 | + $onoff = 'on'; |
|
| 122 | + } elseif ($suite === '_RUBRIQUE') { |
|
| 123 | + $_id_rubrique = champ_sql('id_rubrique', $p); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $code = "quete_logo('$id_objet', '$onoff', $_id_objet, $_id_rubrique)"; |
|
| 126 | + $code = "quete_logo('$id_objet', '$onoff', $_id_objet, $_id_rubrique)"; |
|
| 127 | 127 | |
| 128 | - if ($champ) { |
|
| 129 | - return "table_valeur($code, '" . addslashes($champ) . "')"; |
|
| 130 | - } |
|
| 128 | + if ($champ) { |
|
| 129 | + return "table_valeur($code, '" . addslashes($champ) . "')"; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - $align = preg_replace(',\W,', '', $align); |
|
| 132 | + $align = preg_replace(',\W,', '', $align); |
|
| 133 | 133 | |
| 134 | - return "quete_html_logo($code, '$align', " . ($_lien ?: "''") . ')'; |
|
| 134 | + return "quete_html_logo($code, '$align', " . ($_lien ?: "''") . ')'; |
|
| 135 | 135 | } |
@@ -126,10 +126,10 @@ |
||
| 126 | 126 | $code = "quete_logo('$id_objet', '$onoff', $_id_objet, $_id_rubrique)"; |
| 127 | 127 | |
| 128 | 128 | if ($champ) { |
| 129 | - return "table_valeur($code, '" . addslashes($champ) . "')"; |
|
| 129 | + return "table_valeur($code, '".addslashes($champ)."')"; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | $align = preg_replace(',\W,', '', $align); |
| 133 | 133 | |
| 134 | - return "quete_html_logo($code, '$align', " . ($_lien ?: "''") . ')'; |
|
| 134 | + return "quete_html_logo($code, '$align', ".($_lien ?: "''").')'; |
|
| 135 | 135 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * Pile complétée du code compilé |
| 44 | 44 | **/ |
| 45 | 45 | function balise_FORMULAIRE_INSCRIPTION($p) { |
| 46 | - return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []); |
|
| 46 | + return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', []); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -73,19 +73,19 @@ discard block |
||
| 73 | 73 | * - chaîne vide sinon. |
| 74 | 74 | */ |
| 75 | 75 | function balise_FORMULAIRE_INSCRIPTION_stat($args, $context_compil) { |
| 76 | - [$mode, $id_ou_options, $retour] = array_pad($args, 3, null); |
|
| 76 | + [$mode, $id_ou_options, $retour] = array_pad($args, 3, null); |
|
| 77 | 77 | |
| 78 | - // Compatibilité avec l'ancien param "id" dans les deux sens |
|
| 79 | - if (!is_array($id_ou_options)) { |
|
| 80 | - $options = ['id' => (int) $id_ou_options]; |
|
| 81 | - $id = $options['id']; |
|
| 82 | - }else { |
|
| 83 | - $options = $id_ou_options; |
|
| 84 | - $id = (int) ($id_ou_options['id'] ?? 0); |
|
| 85 | - } |
|
| 78 | + // Compatibilité avec l'ancien param "id" dans les deux sens |
|
| 79 | + if (!is_array($id_ou_options)) { |
|
| 80 | + $options = ['id' => (int) $id_ou_options]; |
|
| 81 | + $id = $options['id']; |
|
| 82 | + }else { |
|
| 83 | + $options = $id_ou_options; |
|
| 84 | + $id = (int) ($id_ou_options['id'] ?? 0); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - include_spip('action/inscrire_auteur'); |
|
| 88 | - $mode = tester_statut_inscription($mode, $id); |
|
| 87 | + include_spip('action/inscrire_auteur'); |
|
| 88 | + $mode = tester_statut_inscription($mode, $id); |
|
| 89 | 89 | |
| 90 | - return $mode ? [$mode, $options, $retour] : ''; |
|
| 90 | + return $mode ? [$mode, $options, $retour] : ''; |
|
| 91 | 91 | } |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | if (!is_array($id_ou_options)) { |
| 80 | 80 | $options = ['id' => (int) $id_ou_options]; |
| 81 | 81 | $id = $options['id']; |
| 82 | - }else { |
|
| 82 | + } else { |
|
| 83 | 83 | $options = $id_ou_options; |
| 84 | 84 | $id = (int) ($id_ou_options['id'] ?? 0); |
| 85 | 85 | } |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | if (!is_array($id_ou_options)) { |
| 80 | 80 | $options = ['id' => (int) $id_ou_options]; |
| 81 | 81 | $id = $options['id']; |
| 82 | - }else { |
|
| 82 | + } else { |
|
| 83 | 83 | $options = $id_ou_options; |
| 84 | 84 | $id = (int) ($id_ou_options['id'] ?? 0); |
| 85 | 85 | } |