@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | sql_updateq( |
| 136 | 136 | 'spip_rubriques', |
| 137 | 137 | ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')], |
| 138 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 138 | + 'id_rubrique='.intval($id_rubrique) |
|
| 139 | 139 | ); |
| 140 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique)); |
|
| 140 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique='.intval($id_rubrique)); |
|
| 141 | 141 | if (!$id_parent) { |
| 142 | 142 | break; |
| 143 | 143 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | return $id_pred != $id_rubrique; |
| 173 | 173 | } |
| 174 | 174 | // passer au parent si on a depublie |
| 175 | - $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred)); |
|
| 175 | + $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id_pred)); |
|
| 176 | 176 | $id_pred = $r['id_parent']; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -197,14 +197,14 @@ discard block |
||
| 197 | 197 | $date = date('Y-m-d H:i:s'); |
| 198 | 198 | } |
| 199 | 199 | $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
| 200 | - ' AND date <= ' . sql_quote($date) : ''; |
|
| 200 | + ' AND date <= '.sql_quote($date) : ''; |
|
| 201 | 201 | |
| 202 | 202 | if (!$id_rubrique = intval($id_rubrique)) { |
| 203 | 203 | return false; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // verifier qu'elle existe et est bien publiee |
| 207 | - $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 207 | + $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 208 | 208 | if (!$r or $r['statut'] !== 'publie') { |
| 209 | 209 | return false; |
| 210 | 210 | } |
@@ -214,12 +214,12 @@ discard block |
||
| 214 | 214 | $compte = [ |
| 215 | 215 | 'articles' => sql_countsel( |
| 216 | 216 | 'spip_articles', |
| 217 | - 'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates" |
|
| 217 | + 'id_rubrique='.intval($id_rubrique)." AND statut='publie'$postdates" |
|
| 218 | 218 | ), |
| 219 | - 'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"), |
|
| 219 | + 'rubriques' => sql_countsel('spip_rubriques', 'id_parent='.intval($id_rubrique)." AND statut='publie'"), |
|
| 220 | 220 | 'documents' => sql_countsel( |
| 221 | 221 | 'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document', |
| 222 | - 'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 222 | + 'L.id_objet='.intval($id_rubrique)." AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 223 | 223 | ) |
| 224 | 224 | ]; |
| 225 | 225 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique)); |
|
| 247 | + sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique='.intval($id_rubrique)); |
|
| 248 | 248 | |
| 249 | 249 | # spip_log("depublier_rubrique $id_pred"); |
| 250 | 250 | return true; |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | |
| 308 | 308 | // Afficher les articles post-dates ? |
| 309 | 309 | $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
| 310 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 310 | + 'AND A.date <= '.sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 311 | 311 | |
| 312 | 312 | $r = sql_select( |
| 313 | 313 | 'R.id_rubrique AS id, max(A.date) AS date_h', |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | sql_updateq( |
| 320 | 320 | 'spip_rubriques', |
| 321 | 321 | ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
| 322 | - 'id_rubrique=' . intval($row['id']) |
|
| 322 | + 'id_rubrique='.intval($row['id']) |
|
| 323 | 323 | ); |
| 324 | 324 | } |
| 325 | 325 | |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | sql_updateq( |
| 346 | 346 | 'spip_rubriques', |
| 347 | 347 | ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
| 348 | - 'id_rubrique=' . intval($row['id']) |
|
| 348 | + 'id_rubrique='.intval($row['id']) |
|
| 349 | 349 | ); |
| 350 | 350 | $continuer = true; |
| 351 | 351 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | and $rows = sql_allfetsel( |
| 399 | 399 | 'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur', |
| 400 | 400 | 'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique', |
| 401 | - 'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 401 | + 'R.profondeur='.intval($prof).' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 402 | 402 | '', |
| 403 | 403 | 'R.id_secteur', |
| 404 | 404 | '0,100' |
@@ -437,11 +437,11 @@ discard block |
||
| 437 | 437 | and $rows = sql_allfetsel( |
| 438 | 438 | 'id_rubrique as id', |
| 439 | 439 | 'spip_rubriques', |
| 440 | - 'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select( |
|
| 440 | + 'profondeur='.intval($prof + 1).' AND id_parent NOT IN ('.sql_get_select( |
|
| 441 | 441 | 'zzz.id_rubrique', |
| 442 | 442 | 'spip_rubriques AS zzz', |
| 443 | - 'zzz.profondeur=' . intval($prof) |
|
| 444 | - ) . ')', |
|
| 443 | + 'zzz.profondeur='.intval($prof) |
|
| 444 | + ).')', |
|
| 445 | 445 | '', |
| 446 | 446 | '', |
| 447 | 447 | '0,100' |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | // si pas de rubrique a profondeur $prof+1 pas la peine de continuer |
| 456 | 456 | // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse) |
| 457 | 457 | // on arrete les frais |
| 458 | - if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) { |
|
| 458 | + if (sql_countsel('spip_rubriques', 'profondeur='.intval($prof + 1))) { |
|
| 459 | 459 | $prof++; |
| 460 | 460 | $continuer = true; |
| 461 | 461 | } |
@@ -463,12 +463,12 @@ discard block |
||
| 463 | 463 | |
| 464 | 464 | // loger si la table des rubriques semble foireuse |
| 465 | 465 | // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles |
| 466 | - if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) { |
|
| 466 | + if (sql_countsel('spip_rubriques', 'profondeur>'.intval($prof + 1))) { |
|
| 467 | 467 | spip_log( |
| 468 | - 'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 468 | + 'Les rubriques de profondeur>'.($prof + 1).' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 469 | 469 | _LOG_CRITIQUE |
| 470 | 470 | ); |
| 471 | - sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1)); |
|
| 471 | + sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>'.intval($prof + 1)); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | // reparer les articles |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | ); |
| 480 | 480 | |
| 481 | 481 | while ($row = sql_fetch($r)) { |
| 482 | - sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id'])); |
|
| 482 | + sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article='.intval($row['id'])); |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | // avertir les plugins qui peuvent faire leur mises a jour egalement |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | $t = sql_updateq( |
| 511 | 511 | 'spip_rubriques', |
| 512 | 512 | ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
| 513 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 513 | + 'id_rubrique='.intval($id_rubrique) |
|
| 514 | 514 | ); |
| 515 | 515 | } |
| 516 | 516 | |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | sql_updateq( |
| 556 | 556 | 'spip_articles', |
| 557 | 557 | ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
| 558 | - 'id_article=' . intval($id_article) |
|
| 558 | + 'id_article='.intval($id_article) |
|
| 559 | 559 | ); |
| 560 | 560 | } |
| 561 | 561 | |
@@ -630,11 +630,11 @@ discard block |
||
| 630 | 630 | ]; |
| 631 | 631 | // generer un nom de fonction "anonyme" unique |
| 632 | 632 | do { |
| 633 | - $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax()); |
|
| 633 | + $functionname = 'f_calculer_langues_utilisees_'.$boucle->id_table.'_'.time().'_'.random_int(0, mt_getrandmax()); |
|
| 634 | 634 | } while (function_exists($functionname)); |
| 635 | 635 | $code = calculer_boucle('calculer_langues_utilisees', $boucles); |
| 636 | - $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code; |
|
| 637 | - $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();'; |
|
| 636 | + $code = '$SP=0; $command=array();$command["connect"] = $connect = "'.$serveur.'"; $Pile=array(0=>array());'."\n".$code; |
|
| 637 | + $code = 'function '.$functionname.'(){'.$code.'};$res = '.$functionname.'();'; |
|
| 638 | 638 | $res = ''; |
| 639 | 639 | eval($code); |
| 640 | 640 | $res = explode(',', $res); |
@@ -736,11 +736,11 @@ discard block |
||
| 736 | 736 | $maxiter-- and $filles = sql_allfetsel( |
| 737 | 737 | 'id_rubrique', |
| 738 | 738 | 'spip_rubriques', |
| 739 | - sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT') |
|
| 739 | + sql_in('id_parent', $r).' AND '.sql_in('id_rubrique', $r, 'NOT') |
|
| 740 | 740 | ) |
| 741 | 741 | ) { |
| 742 | 742 | $r = join(',', array_column($filles, 'id_rubrique')); |
| 743 | - $branche .= ',' . $r; |
|
| 743 | + $branche .= ','.$r; |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | |
| 781 | 781 | if (isset($b[$id])) { |
| 782 | 782 | // Notre branche commence par la rubrique de depart si $tout=true |
| 783 | - return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id]; |
|
| 783 | + return $tout ? (strlen($b[$id]) ? $b[$id].",$id" : $id) : $b[$id]; |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | $hier = ''; |
@@ -793,11 +793,11 @@ discard block |
||
| 793 | 793 | $maxiter-- and $parents = sql_allfetsel( |
| 794 | 794 | 'id_parent', |
| 795 | 795 | 'spip_rubriques', |
| 796 | - sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT') |
|
| 796 | + sql_in('id_rubrique', $ids_nouveaux_parents).' AND '.sql_in('id_parent', $hier, 'NOT') |
|
| 797 | 797 | ) |
| 798 | 798 | ) { |
| 799 | 799 | $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent')); |
| 800 | - $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : ''); |
|
| 800 | + $hier = $ids_nouveaux_parents.(strlen($hier) ? ','.$hier : ''); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | include_spip('base/abstract_sql'); |
| 830 | 830 | if ($check) { |
| 831 | 831 | $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
| 832 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 832 | + 'AND A.date <= '.sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 833 | 833 | |
| 834 | 834 | $r = sql_select( |
| 835 | 835 | 'DISTINCT A.id_rubrique AS id', |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | $t = sql_fetsel( |
| 847 | 847 | 'date', |
| 848 | 848 | 'spip_articles', |
| 849 | - "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), |
|
| 849 | + "statut='publie' AND date > ".sql_quote(date('Y-m-d H:i:s')), |
|
| 850 | 850 | '', |
| 851 | 851 | 'date', |
| 852 | 852 | '1' |
@@ -902,7 +902,7 @@ discard block |
||
| 902 | 902 | $r = sql_getfetsel( |
| 903 | 903 | 'id_rubrique', |
| 904 | 904 | 'spip_rubriques', |
| 905 | - 'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent), |
|
| 905 | + 'titre = '.sql_quote($titre).' AND id_parent='.intval($id_parent), |
|
| 906 | 906 | $groupby = [], |
| 907 | 907 | $orderby = [], |
| 908 | 908 | $limit = '', |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | sql_updateq( |
| 939 | 939 | 'spip_rubriques', |
| 940 | 940 | ['id_secteur' => $id_secteur, 'lang' => $lang], |
| 941 | - 'id_rubrique=' . intval($id_rubrique), |
|
| 941 | + 'id_rubrique='.intval($id_rubrique), |
|
| 942 | 942 | [], |
| 943 | 943 | $serveur |
| 944 | 944 | ); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -55,65 +55,65 @@ discard block |
||
| 55 | 55 | * @return void |
| 56 | 56 | **/ |
| 57 | 57 | function calculer_rubriques_if($id_rubrique, $modifs, $infos = [], $postdate = false) { |
| 58 | - $statuts_publies = null; |
|
| 59 | - $neuf = false; |
|
| 60 | - |
|
| 61 | - // Compat avec l'ancienne signature |
|
| 62 | - if (is_string($infos)) { |
|
| 63 | - $infos = ['statut_ancien' => $infos]; |
|
| 64 | - } |
|
| 65 | - if (!isset($infos['statut_ancien'])) { |
|
| 66 | - $infos['statut_ancien'] = ''; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - // On recherche quels statuts tester |
|
| 70 | - if ( |
|
| 71 | - isset($infos['objet']) |
|
| 72 | - and include_spip('inc/filtres') |
|
| 73 | - and $declaration_statut = objet_info($infos['objet'], 'statut') |
|
| 74 | - and is_array($declaration_statut) |
|
| 75 | - ) { |
|
| 76 | - foreach ($declaration_statut as $champ_statut) { |
|
| 77 | - if ($champ_statut['champ'] == 'statut') { |
|
| 78 | - $statuts_publies = array_map('trim', explode(',', $champ_statut['publie'])); |
|
| 79 | - break; // stop on a trouvé le bon champ |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - } else { |
|
| 83 | - $statuts_publies = ['publie']; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - if (in_array($infos['statut_ancien'], $statuts_publies)) { |
|
| 87 | - if ( |
|
| 88 | - isset($modifs['statut']) |
|
| 89 | - or isset($modifs['id_rubrique']) |
|
| 90 | - or ($postdate and strtotime($postdate) > time()) |
|
| 91 | - ) { |
|
| 92 | - $neuf |= depublier_branche_rubrique_if($id_rubrique); |
|
| 93 | - } |
|
| 94 | - // ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur |
|
| 95 | - if ($postdate) { |
|
| 96 | - calculer_prochain_postdate(true); |
|
| 97 | - $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 98 | - } elseif (isset($modifs['id_rubrique'])) { |
|
| 99 | - $neuf |= publier_branche_rubrique($modifs['id_rubrique']); |
|
| 100 | - } |
|
| 101 | - } elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) { |
|
| 102 | - if ($postdate) { |
|
| 103 | - calculer_prochain_postdate(true); |
|
| 104 | - $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 105 | - } else { |
|
| 106 | - $neuf |= publier_branche_rubrique($id_rubrique); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - if ($neuf) { |
|
| 111 | - // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 112 | - ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $langues = calculer_langues_utilisees(); |
|
| 116 | - ecrire_meta('langues_utilisees', $langues); |
|
| 58 | + $statuts_publies = null; |
|
| 59 | + $neuf = false; |
|
| 60 | + |
|
| 61 | + // Compat avec l'ancienne signature |
|
| 62 | + if (is_string($infos)) { |
|
| 63 | + $infos = ['statut_ancien' => $infos]; |
|
| 64 | + } |
|
| 65 | + if (!isset($infos['statut_ancien'])) { |
|
| 66 | + $infos['statut_ancien'] = ''; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + // On recherche quels statuts tester |
|
| 70 | + if ( |
|
| 71 | + isset($infos['objet']) |
|
| 72 | + and include_spip('inc/filtres') |
|
| 73 | + and $declaration_statut = objet_info($infos['objet'], 'statut') |
|
| 74 | + and is_array($declaration_statut) |
|
| 75 | + ) { |
|
| 76 | + foreach ($declaration_statut as $champ_statut) { |
|
| 77 | + if ($champ_statut['champ'] == 'statut') { |
|
| 78 | + $statuts_publies = array_map('trim', explode(',', $champ_statut['publie'])); |
|
| 79 | + break; // stop on a trouvé le bon champ |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + } else { |
|
| 83 | + $statuts_publies = ['publie']; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + if (in_array($infos['statut_ancien'], $statuts_publies)) { |
|
| 87 | + if ( |
|
| 88 | + isset($modifs['statut']) |
|
| 89 | + or isset($modifs['id_rubrique']) |
|
| 90 | + or ($postdate and strtotime($postdate) > time()) |
|
| 91 | + ) { |
|
| 92 | + $neuf |= depublier_branche_rubrique_if($id_rubrique); |
|
| 93 | + } |
|
| 94 | + // ne publier que si c'est pas un postdate, ou si la date n'est pas dans le futur |
|
| 95 | + if ($postdate) { |
|
| 96 | + calculer_prochain_postdate(true); |
|
| 97 | + $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 98 | + } elseif (isset($modifs['id_rubrique'])) { |
|
| 99 | + $neuf |= publier_branche_rubrique($modifs['id_rubrique']); |
|
| 100 | + } |
|
| 101 | + } elseif (isset($modifs['statut']) and in_array($modifs['statut'], $statuts_publies)) { |
|
| 102 | + if ($postdate) { |
|
| 103 | + calculer_prochain_postdate(true); |
|
| 104 | + $neuf |= (strtotime($postdate) <= time()); // par securite |
|
| 105 | + } else { |
|
| 106 | + $neuf |= publier_branche_rubrique($id_rubrique); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + if ($neuf) { |
|
| 111 | + // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 112 | + ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $langues = calculer_langues_utilisees(); |
|
| 116 | + ecrire_meta('langues_utilisees', $langues); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -131,22 +131,22 @@ discard block |
||
| 131 | 131 | * true si le statut change effectivement |
| 132 | 132 | */ |
| 133 | 133 | function publier_branche_rubrique($id_rubrique) { |
| 134 | - $id_pred = $id_rubrique; |
|
| 135 | - while (true) { |
|
| 136 | - sql_updateq( |
|
| 137 | - 'spip_rubriques', |
|
| 138 | - ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')], |
|
| 139 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 140 | - ); |
|
| 141 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique)); |
|
| 142 | - if (!$id_parent) { |
|
| 143 | - break; |
|
| 144 | - } |
|
| 145 | - $id_rubrique = $id_parent; |
|
| 146 | - } |
|
| 134 | + $id_pred = $id_rubrique; |
|
| 135 | + while (true) { |
|
| 136 | + sql_updateq( |
|
| 137 | + 'spip_rubriques', |
|
| 138 | + ['statut' => 'publie', 'date' => date('Y-m-d H:i:s')], |
|
| 139 | + 'id_rubrique=' . intval($id_rubrique) |
|
| 140 | + ); |
|
| 141 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques AS R', 'R.id_rubrique=' . intval($id_rubrique)); |
|
| 142 | + if (!$id_parent) { |
|
| 143 | + break; |
|
| 144 | + } |
|
| 145 | + $id_rubrique = $id_parent; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | 148 | # spip_log(" publier_branche_rubrique($id_rubrique $id_pred"); |
| 149 | - return $id_pred != $id_rubrique; |
|
| 149 | + return $id_pred != $id_rubrique; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -164,20 +164,20 @@ discard block |
||
| 164 | 164 | * true si le statut change effectivement |
| 165 | 165 | */ |
| 166 | 166 | function depublier_branche_rubrique_if($id_rubrique) { |
| 167 | - $date = date('Y-m-d H:i:s'); // figer la date |
|
| 168 | - |
|
| 169 | - # spip_log("depublier_branche_rubrique($id_rubrique ?"); |
|
| 170 | - $id_pred = $id_rubrique; |
|
| 171 | - while ($id_pred) { |
|
| 172 | - if (!depublier_rubrique_if($id_pred, $date)) { |
|
| 173 | - return $id_pred != $id_rubrique; |
|
| 174 | - } |
|
| 175 | - // passer au parent si on a depublie |
|
| 176 | - $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred)); |
|
| 177 | - $id_pred = $r['id_parent']; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - return $id_pred != $id_rubrique; |
|
| 167 | + $date = date('Y-m-d H:i:s'); // figer la date |
|
| 168 | + |
|
| 169 | + # spip_log("depublier_branche_rubrique($id_rubrique ?"); |
|
| 170 | + $id_pred = $id_rubrique; |
|
| 171 | + while ($id_pred) { |
|
| 172 | + if (!depublier_rubrique_if($id_pred, $date)) { |
|
| 173 | + return $id_pred != $id_rubrique; |
|
| 174 | + } |
|
| 175 | + // passer au parent si on a depublie |
|
| 176 | + $r = sql_fetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id_pred)); |
|
| 177 | + $id_pred = $r['id_parent']; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + return $id_pred != $id_rubrique; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -194,61 +194,61 @@ discard block |
||
| 194 | 194 | * true si la rubrique a été dépubliée |
| 195 | 195 | */ |
| 196 | 196 | function depublier_rubrique_if($id_rubrique, $date = null) { |
| 197 | - if (is_null($date)) { |
|
| 198 | - $date = date('Y-m-d H:i:s'); |
|
| 199 | - } |
|
| 200 | - $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 201 | - ' AND date <= ' . sql_quote($date) : ''; |
|
| 202 | - |
|
| 203 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 204 | - return false; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - // verifier qu'elle existe et est bien publiee |
|
| 208 | - $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 209 | - if (!$r or $r['statut'] !== 'publie') { |
|
| 210 | - return false; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - // On met le nombre de chaque type d'enfants dans un tableau |
|
| 214 | - // Le type de l'objet est au pluriel |
|
| 215 | - $compte = [ |
|
| 216 | - 'articles' => sql_countsel( |
|
| 217 | - 'spip_articles', |
|
| 218 | - 'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates" |
|
| 219 | - ), |
|
| 220 | - 'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"), |
|
| 221 | - 'documents' => sql_countsel( |
|
| 222 | - 'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document', |
|
| 223 | - 'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 224 | - ) |
|
| 225 | - ]; |
|
| 226 | - |
|
| 227 | - // On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants |
|
| 228 | - $compte = pipeline( |
|
| 229 | - 'objet_compte_enfants', |
|
| 230 | - [ |
|
| 231 | - 'args' => [ |
|
| 232 | - 'objet' => 'rubrique', |
|
| 233 | - 'id_objet' => $id_rubrique, |
|
| 234 | - 'statut' => 'publie', |
|
| 235 | - 'date' => $date |
|
| 236 | - ], |
|
| 237 | - 'data' => $compte |
|
| 238 | - ] |
|
| 239 | - ); |
|
| 240 | - |
|
| 241 | - // S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas |
|
| 242 | - foreach ($compte as $objet => $n) { |
|
| 243 | - if ($n) { |
|
| 244 | - return false; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique)); |
|
| 197 | + if (is_null($date)) { |
|
| 198 | + $date = date('Y-m-d H:i:s'); |
|
| 199 | + } |
|
| 200 | + $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 201 | + ' AND date <= ' . sql_quote($date) : ''; |
|
| 202 | + |
|
| 203 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 204 | + return false; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + // verifier qu'elle existe et est bien publiee |
|
| 208 | + $r = sql_fetsel('id_rubrique,statut', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 209 | + if (!$r or $r['statut'] !== 'publie') { |
|
| 210 | + return false; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + // On met le nombre de chaque type d'enfants dans un tableau |
|
| 214 | + // Le type de l'objet est au pluriel |
|
| 215 | + $compte = [ |
|
| 216 | + 'articles' => sql_countsel( |
|
| 217 | + 'spip_articles', |
|
| 218 | + 'id_rubrique=' . intval($id_rubrique) . " AND statut='publie'$postdates" |
|
| 219 | + ), |
|
| 220 | + 'rubriques' => sql_countsel('spip_rubriques', 'id_parent=' . intval($id_rubrique) . " AND statut='publie'"), |
|
| 221 | + 'documents' => sql_countsel( |
|
| 222 | + 'spip_documents AS D JOIN spip_documents_liens AS L ON D.id_document=L.id_document', |
|
| 223 | + 'L.id_objet=' . intval($id_rubrique) . " AND L.objet='rubrique' and D.mode NOT IN('logoon', 'logooff') " |
|
| 224 | + ) |
|
| 225 | + ]; |
|
| 226 | + |
|
| 227 | + // On passe le tableau des comptes dans un pipeline pour que les plugins puissent ajouter (ou retirer) des enfants |
|
| 228 | + $compte = pipeline( |
|
| 229 | + 'objet_compte_enfants', |
|
| 230 | + [ |
|
| 231 | + 'args' => [ |
|
| 232 | + 'objet' => 'rubrique', |
|
| 233 | + 'id_objet' => $id_rubrique, |
|
| 234 | + 'statut' => 'publie', |
|
| 235 | + 'date' => $date |
|
| 236 | + ], |
|
| 237 | + 'data' => $compte |
|
| 238 | + ] |
|
| 239 | + ); |
|
| 240 | + |
|
| 241 | + // S'il y a au moins un enfant de n'importe quoi, on ne dépublie pas |
|
| 242 | + foreach ($compte as $objet => $n) { |
|
| 243 | + if ($n) { |
|
| 244 | + return false; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + sql_updateq('spip_rubriques', ['statut' => 'prepa'], 'id_rubrique=' . intval($id_rubrique)); |
|
| 249 | 249 | |
| 250 | 250 | # spip_log("depublier_rubrique $id_pred"); |
| 251 | - return true; |
|
| 251 | + return true; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | |
@@ -271,18 +271,18 @@ discard block |
||
| 271 | 271 | **/ |
| 272 | 272 | function calculer_rubriques() { |
| 273 | 273 | |
| 274 | - calculer_rubriques_publiees(); |
|
| 274 | + calculer_rubriques_publiees(); |
|
| 275 | 275 | |
| 276 | - // Apres chaque (de)publication |
|
| 277 | - // recalculer les langues utilisees sur le site |
|
| 278 | - $langues = calculer_langues_utilisees(); |
|
| 279 | - ecrire_meta('langues_utilisees', $langues); |
|
| 276 | + // Apres chaque (de)publication |
|
| 277 | + // recalculer les langues utilisees sur le site |
|
| 278 | + $langues = calculer_langues_utilisees(); |
|
| 279 | + ecrire_meta('langues_utilisees', $langues); |
|
| 280 | 280 | |
| 281 | - // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 282 | - ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 281 | + // Sauver la date de la derniere mise a jour (pour menu_rubriques) |
|
| 282 | + ecrire_meta('date_calcul_rubriques', date('U')); |
|
| 283 | 283 | |
| 284 | - // on calcule la date du prochain article post-date |
|
| 285 | - calculer_prochain_postdate(); |
|
| 284 | + // on calcule la date du prochain article post-date |
|
| 285 | + calculer_prochain_postdate(); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | |
@@ -299,61 +299,61 @@ discard block |
||
| 299 | 299 | **/ |
| 300 | 300 | function calculer_rubriques_publiees() { |
| 301 | 301 | |
| 302 | - // Mettre les compteurs a zero |
|
| 303 | - sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']); |
|
| 304 | - |
|
| 305 | - // |
|
| 306 | - // Publier et dater les rubriques qui ont un article publie |
|
| 307 | - // |
|
| 308 | - |
|
| 309 | - // Afficher les articles post-dates ? |
|
| 310 | - $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 311 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 312 | - |
|
| 313 | - $r = sql_select( |
|
| 314 | - 'R.id_rubrique AS id, max(A.date) AS date_h', |
|
| 315 | - 'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique', |
|
| 316 | - "A.date>R.date_tmp AND A.statut='publie' $postdates ", |
|
| 317 | - 'R.id_rubrique' |
|
| 318 | - ); |
|
| 319 | - while ($row = sql_fetch($r)) { |
|
| 320 | - sql_updateq( |
|
| 321 | - 'spip_rubriques', |
|
| 322 | - ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 323 | - 'id_rubrique=' . intval($row['id']) |
|
| 324 | - ); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - // point d'entree pour permettre a des plugins de gerer le statut |
|
| 328 | - // autrement (par ex: toute rubrique est publiee des sa creation) |
|
| 329 | - // Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates |
|
| 330 | - // c'est statut_tmp/date_tmp qu'il doit modifier |
|
| 331 | - // [C'est un trigger... a renommer en trig_calculer_rubriques ?] |
|
| 332 | - pipeline('calculer_rubriques', null); |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - // Les rubriques qui ont une rubrique fille plus recente |
|
| 336 | - // on tourne tant que les donnees remontent vers la racine. |
|
| 337 | - do { |
|
| 338 | - $continuer = false; |
|
| 339 | - $r = sql_select( |
|
| 340 | - 'R.id_rubrique AS id, max(SR.date_tmp) AS date_h', |
|
| 341 | - 'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent', |
|
| 342 | - "(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ", |
|
| 343 | - 'R.id_rubrique' |
|
| 344 | - ); |
|
| 345 | - while ($row = sql_fetch($r)) { |
|
| 346 | - sql_updateq( |
|
| 347 | - 'spip_rubriques', |
|
| 348 | - ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 349 | - 'id_rubrique=' . intval($row['id']) |
|
| 350 | - ); |
|
| 351 | - $continuer = true; |
|
| 352 | - } |
|
| 353 | - } while ($continuer); |
|
| 354 | - |
|
| 355 | - // Enregistrement des modifs |
|
| 356 | - sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']); |
|
| 302 | + // Mettre les compteurs a zero |
|
| 303 | + sql_updateq('spip_rubriques', ['date_tmp' => '0000-00-00 00:00:00', 'statut_tmp' => 'prepa']); |
|
| 304 | + |
|
| 305 | + // |
|
| 306 | + // Publier et dater les rubriques qui ont un article publie |
|
| 307 | + // |
|
| 308 | + |
|
| 309 | + // Afficher les articles post-dates ? |
|
| 310 | + $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 311 | + 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 312 | + |
|
| 313 | + $r = sql_select( |
|
| 314 | + 'R.id_rubrique AS id, max(A.date) AS date_h', |
|
| 315 | + 'spip_rubriques AS R JOIN spip_articles AS A ON R.id_rubrique = A.id_rubrique', |
|
| 316 | + "A.date>R.date_tmp AND A.statut='publie' $postdates ", |
|
| 317 | + 'R.id_rubrique' |
|
| 318 | + ); |
|
| 319 | + while ($row = sql_fetch($r)) { |
|
| 320 | + sql_updateq( |
|
| 321 | + 'spip_rubriques', |
|
| 322 | + ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 323 | + 'id_rubrique=' . intval($row['id']) |
|
| 324 | + ); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + // point d'entree pour permettre a des plugins de gerer le statut |
|
| 328 | + // autrement (par ex: toute rubrique est publiee des sa creation) |
|
| 329 | + // Ce pipeline fait ce qu'il veut, mais s'il touche aux statuts/dates |
|
| 330 | + // c'est statut_tmp/date_tmp qu'il doit modifier |
|
| 331 | + // [C'est un trigger... a renommer en trig_calculer_rubriques ?] |
|
| 332 | + pipeline('calculer_rubriques', null); |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + // Les rubriques qui ont une rubrique fille plus recente |
|
| 336 | + // on tourne tant que les donnees remontent vers la racine. |
|
| 337 | + do { |
|
| 338 | + $continuer = false; |
|
| 339 | + $r = sql_select( |
|
| 340 | + 'R.id_rubrique AS id, max(SR.date_tmp) AS date_h', |
|
| 341 | + 'spip_rubriques AS R JOIN spip_rubriques AS SR ON R.id_rubrique = SR.id_parent', |
|
| 342 | + "(SR.date_tmp>R.date_tmp OR R.statut_tmp<>'publie') AND SR.statut_tmp='publie' ", |
|
| 343 | + 'R.id_rubrique' |
|
| 344 | + ); |
|
| 345 | + while ($row = sql_fetch($r)) { |
|
| 346 | + sql_updateq( |
|
| 347 | + 'spip_rubriques', |
|
| 348 | + ['statut_tmp' => 'publie', 'date_tmp' => $row['date_h']], |
|
| 349 | + 'id_rubrique=' . intval($row['id']) |
|
| 350 | + ); |
|
| 351 | + $continuer = true; |
|
| 352 | + } |
|
| 353 | + } while ($continuer); |
|
| 354 | + |
|
| 355 | + // Enregistrement des modifs |
|
| 356 | + sql_update('spip_rubriques', ['date' => 'date_tmp', 'statut' => 'statut_tmp']); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -368,123 +368,123 @@ discard block |
||
| 368 | 368 | * @return void |
| 369 | 369 | **/ |
| 370 | 370 | function propager_les_secteurs() { |
| 371 | - // Profondeur 0 |
|
| 372 | - // Toutes les rubriques racines sont de profondeur 0 |
|
| 373 | - // et fixer les id_secteur des rubriques racines |
|
| 374 | - sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0'); |
|
| 375 | - // Toute rubrique non racine est de profondeur >0 |
|
| 376 | - sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0'); |
|
| 377 | - |
|
| 378 | - // securite : pas plus d'iteration que de rubriques dans la base |
|
| 379 | - $maxiter = sql_countsel('spip_rubriques'); |
|
| 380 | - |
|
| 381 | - // reparer les rubriques qui n'ont pas l'id_secteur de leur parent |
|
| 382 | - // on fait profondeur par profondeur |
|
| 383 | - |
|
| 384 | - $prof = 0; |
|
| 385 | - do { |
|
| 386 | - $continuer = false; |
|
| 387 | - |
|
| 388 | - // Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes |
|
| 389 | - // on fixe le profondeur $prof+1 |
|
| 390 | - |
|
| 391 | - // Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1 |
|
| 392 | - // on teste A.profondeur > $prof+1 car : |
|
| 393 | - // - toutes les rubriques de profondeur 0 à $prof sont bonnes |
|
| 394 | - // - si A.profondeur = $prof+1 c'est bon |
|
| 395 | - // - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques |
|
| 396 | - $maxiter2 = $maxiter; |
|
| 397 | - while ( |
|
| 398 | - $maxiter2-- |
|
| 399 | - and $rows = sql_allfetsel( |
|
| 400 | - 'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur', |
|
| 401 | - 'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique', |
|
| 402 | - 'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 403 | - '', |
|
| 404 | - 'R.id_secteur', |
|
| 405 | - '0,100' |
|
| 406 | - ) |
|
| 407 | - ) { |
|
| 408 | - $id_secteur = null; |
|
| 409 | - $ids = []; |
|
| 410 | - while ($row = array_shift($rows)) { |
|
| 411 | - if ($row['id_secteur'] !== $id_secteur) { |
|
| 412 | - if (count($ids)) { |
|
| 413 | - sql_updateq( |
|
| 414 | - 'spip_rubriques', |
|
| 415 | - ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 416 | - sql_in('id_rubrique', $ids) |
|
| 417 | - ); |
|
| 418 | - } |
|
| 419 | - $id_secteur = $row['id_secteur']; |
|
| 420 | - $ids = []; |
|
| 421 | - } |
|
| 422 | - $ids[] = $row['id']; |
|
| 423 | - } |
|
| 424 | - if (count($ids)) { |
|
| 425 | - sql_updateq( |
|
| 426 | - 'spip_rubriques', |
|
| 427 | - ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 428 | - sql_in('id_rubrique', $ids) |
|
| 429 | - ); |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - |
|
| 434 | - // Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees |
|
| 435 | - $maxiter2 = $maxiter; |
|
| 436 | - while ( |
|
| 437 | - $maxiter2-- |
|
| 438 | - and $rows = sql_allfetsel( |
|
| 439 | - 'id_rubrique as id', |
|
| 440 | - 'spip_rubriques', |
|
| 441 | - 'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select( |
|
| 442 | - 'zzz.id_rubrique', |
|
| 443 | - 'spip_rubriques AS zzz', |
|
| 444 | - 'zzz.profondeur=' . intval($prof) |
|
| 445 | - ) . ')', |
|
| 446 | - '', |
|
| 447 | - '', |
|
| 448 | - '0,100' |
|
| 449 | - ) |
|
| 450 | - ) { |
|
| 451 | - $rows = array_column($rows, 'id'); |
|
| 452 | - sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows)); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - // ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK |
|
| 456 | - // si pas de rubrique a profondeur $prof+1 pas la peine de continuer |
|
| 457 | - // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse) |
|
| 458 | - // on arrete les frais |
|
| 459 | - if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) { |
|
| 460 | - $prof++; |
|
| 461 | - $continuer = true; |
|
| 462 | - } |
|
| 463 | - } while ($continuer and $maxiter--); |
|
| 464 | - |
|
| 465 | - // loger si la table des rubriques semble foireuse |
|
| 466 | - // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles |
|
| 467 | - if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) { |
|
| 468 | - spip_log( |
|
| 469 | - 'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 470 | - _LOG_CRITIQUE |
|
| 471 | - ); |
|
| 472 | - sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1)); |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - // reparer les articles |
|
| 476 | - $r = sql_select( |
|
| 477 | - 'A.id_article AS id, R.id_secteur AS secteur', |
|
| 478 | - 'spip_articles AS A, spip_rubriques AS R', |
|
| 479 | - 'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur' |
|
| 480 | - ); |
|
| 481 | - |
|
| 482 | - while ($row = sql_fetch($r)) { |
|
| 483 | - sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id'])); |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 487 | - pipeline('trig_propager_les_secteurs', ''); |
|
| 371 | + // Profondeur 0 |
|
| 372 | + // Toutes les rubriques racines sont de profondeur 0 |
|
| 373 | + // et fixer les id_secteur des rubriques racines |
|
| 374 | + sql_update('spip_rubriques', ['id_secteur' => 'id_rubrique', 'profondeur' => 0], 'id_parent=0'); |
|
| 375 | + // Toute rubrique non racine est de profondeur >0 |
|
| 376 | + sql_updateq('spip_rubriques', ['profondeur' => 1], 'id_parent<>0 AND profondeur=0'); |
|
| 377 | + |
|
| 378 | + // securite : pas plus d'iteration que de rubriques dans la base |
|
| 379 | + $maxiter = sql_countsel('spip_rubriques'); |
|
| 380 | + |
|
| 381 | + // reparer les rubriques qui n'ont pas l'id_secteur de leur parent |
|
| 382 | + // on fait profondeur par profondeur |
|
| 383 | + |
|
| 384 | + $prof = 0; |
|
| 385 | + do { |
|
| 386 | + $continuer = false; |
|
| 387 | + |
|
| 388 | + // Par recursivite : si toutes les rubriques de profondeur $prof sont bonnes |
|
| 389 | + // on fixe le profondeur $prof+1 |
|
| 390 | + |
|
| 391 | + // Toutes les rubriques dont le parent est de profondeur $prof ont une profondeur $prof+1 |
|
| 392 | + // on teste A.profondeur > $prof+1 car : |
|
| 393 | + // - toutes les rubriques de profondeur 0 à $prof sont bonnes |
|
| 394 | + // - si A.profondeur = $prof+1 c'est bon |
|
| 395 | + // - cela nous protege de la boucle infinie en cas de reference circulaire dans les rubriques |
|
| 396 | + $maxiter2 = $maxiter; |
|
| 397 | + while ( |
|
| 398 | + $maxiter2-- |
|
| 399 | + and $rows = sql_allfetsel( |
|
| 400 | + 'A.id_rubrique AS id, R.id_secteur AS id_secteur, R.profondeur+1 as profondeur', |
|
| 401 | + 'spip_rubriques AS A JOIN spip_rubriques AS R ON A.id_parent = R.id_rubrique', |
|
| 402 | + 'R.profondeur=' . intval($prof) . ' AND (A.id_secteur <> R.id_secteur OR A.profondeur > R.profondeur+1)', |
|
| 403 | + '', |
|
| 404 | + 'R.id_secteur', |
|
| 405 | + '0,100' |
|
| 406 | + ) |
|
| 407 | + ) { |
|
| 408 | + $id_secteur = null; |
|
| 409 | + $ids = []; |
|
| 410 | + while ($row = array_shift($rows)) { |
|
| 411 | + if ($row['id_secteur'] !== $id_secteur) { |
|
| 412 | + if (count($ids)) { |
|
| 413 | + sql_updateq( |
|
| 414 | + 'spip_rubriques', |
|
| 415 | + ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 416 | + sql_in('id_rubrique', $ids) |
|
| 417 | + ); |
|
| 418 | + } |
|
| 419 | + $id_secteur = $row['id_secteur']; |
|
| 420 | + $ids = []; |
|
| 421 | + } |
|
| 422 | + $ids[] = $row['id']; |
|
| 423 | + } |
|
| 424 | + if (count($ids)) { |
|
| 425 | + sql_updateq( |
|
| 426 | + 'spip_rubriques', |
|
| 427 | + ['id_secteur' => $id_secteur, 'profondeur' => $prof + 1], |
|
| 428 | + sql_in('id_rubrique', $ids) |
|
| 429 | + ); |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + |
|
| 434 | + // Toutes les rubriques de profondeur $prof+1 qui n'ont pas un parent de profondeur $prof sont decalees |
|
| 435 | + $maxiter2 = $maxiter; |
|
| 436 | + while ( |
|
| 437 | + $maxiter2-- |
|
| 438 | + and $rows = sql_allfetsel( |
|
| 439 | + 'id_rubrique as id', |
|
| 440 | + 'spip_rubriques', |
|
| 441 | + 'profondeur=' . intval($prof + 1) . ' AND id_parent NOT IN (' . sql_get_select( |
|
| 442 | + 'zzz.id_rubrique', |
|
| 443 | + 'spip_rubriques AS zzz', |
|
| 444 | + 'zzz.profondeur=' . intval($prof) |
|
| 445 | + ) . ')', |
|
| 446 | + '', |
|
| 447 | + '', |
|
| 448 | + '0,100' |
|
| 449 | + ) |
|
| 450 | + ) { |
|
| 451 | + $rows = array_column($rows, 'id'); |
|
| 452 | + sql_updateq('spip_rubriques', ['profondeur' => $prof + 2], sql_in('id_rubrique', $rows)); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + // ici on a fini de valider $prof+1, toutes les rubriques de prondeur 0 a $prof+1 sont OK |
|
| 456 | + // si pas de rubrique a profondeur $prof+1 pas la peine de continuer |
|
| 457 | + // si il reste des rubriques non vues, c'est une branche morte ou reference circulaire (base foireuse) |
|
| 458 | + // on arrete les frais |
|
| 459 | + if (sql_countsel('spip_rubriques', 'profondeur=' . intval($prof + 1))) { |
|
| 460 | + $prof++; |
|
| 461 | + $continuer = true; |
|
| 462 | + } |
|
| 463 | + } while ($continuer and $maxiter--); |
|
| 464 | + |
|
| 465 | + // loger si la table des rubriques semble foireuse |
|
| 466 | + // et mettre un id_secteur=0 sur ces rubriques pour eviter toute selection par les boucles |
|
| 467 | + if (sql_countsel('spip_rubriques', 'profondeur>' . intval($prof + 1))) { |
|
| 468 | + spip_log( |
|
| 469 | + 'Les rubriques de profondeur>' . ($prof + 1) . ' semblent suspectes (branches morte ou reference circulaire dans les parents)', |
|
| 470 | + _LOG_CRITIQUE |
|
| 471 | + ); |
|
| 472 | + sql_update('spip_rubriques', ['id_secteur' => 0], 'profondeur>' . intval($prof + 1)); |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + // reparer les articles |
|
| 476 | + $r = sql_select( |
|
| 477 | + 'A.id_article AS id, R.id_secteur AS secteur', |
|
| 478 | + 'spip_articles AS A, spip_rubriques AS R', |
|
| 479 | + 'A.id_rubrique = R.id_rubrique AND A.id_secteur <> R.id_secteur' |
|
| 480 | + ); |
|
| 481 | + |
|
| 482 | + while ($row = sql_fetch($r)) { |
|
| 483 | + sql_update('spip_articles', ['id_secteur' => $row['secteur']], 'id_article=' . intval($row['id'])); |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 487 | + pipeline('trig_propager_les_secteurs', ''); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
@@ -499,23 +499,23 @@ discard block |
||
| 499 | 499 | * true si un changement a eu lieu |
| 500 | 500 | **/ |
| 501 | 501 | function calculer_langues_rubriques_etape() { |
| 502 | - $s = sql_select( |
|
| 503 | - 'A.id_rubrique AS id_rubrique, R.lang AS lang', |
|
| 504 | - 'spip_rubriques AS A, spip_rubriques AS R', |
|
| 505 | - "A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang" |
|
| 506 | - ); |
|
| 507 | - |
|
| 508 | - $t = false; |
|
| 509 | - while ($row = sql_fetch($s)) { |
|
| 510 | - $id_rubrique = $row['id_rubrique']; |
|
| 511 | - $t = sql_updateq( |
|
| 512 | - 'spip_rubriques', |
|
| 513 | - ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 514 | - 'id_rubrique=' . intval($id_rubrique) |
|
| 515 | - ); |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - return $t; |
|
| 502 | + $s = sql_select( |
|
| 503 | + 'A.id_rubrique AS id_rubrique, R.lang AS lang', |
|
| 504 | + 'spip_rubriques AS A, spip_rubriques AS R', |
|
| 505 | + "A.id_parent = R.id_rubrique AND A.langue_choisie != 'oui' AND R.lang<>'' AND R.lang<>A.lang" |
|
| 506 | + ); |
|
| 507 | + |
|
| 508 | + $t = false; |
|
| 509 | + while ($row = sql_fetch($s)) { |
|
| 510 | + $id_rubrique = $row['id_rubrique']; |
|
| 511 | + $t = sql_updateq( |
|
| 512 | + 'spip_rubriques', |
|
| 513 | + ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 514 | + 'id_rubrique=' . intval($id_rubrique) |
|
| 515 | + ); |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + return $t; |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -535,38 +535,38 @@ discard block |
||
| 535 | 535 | **/ |
| 536 | 536 | function calculer_langues_rubriques() { |
| 537 | 537 | |
| 538 | - // rubriques (recursivite) |
|
| 539 | - sql_updateq( |
|
| 540 | - 'spip_rubriques', |
|
| 541 | - ['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'], |
|
| 542 | - "id_parent=0 AND langue_choisie != 'oui'" |
|
| 543 | - ); |
|
| 544 | - while (calculer_langues_rubriques_etape()) { |
|
| 545 | - ; |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - // articles |
|
| 549 | - $s = sql_select( |
|
| 550 | - 'A.id_article AS id_article, R.lang AS lang', |
|
| 551 | - 'spip_articles AS A, spip_rubriques AS R', |
|
| 552 | - "A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang" |
|
| 553 | - ); |
|
| 554 | - while ($row = sql_fetch($s)) { |
|
| 555 | - $id_article = $row['id_article']; |
|
| 556 | - sql_updateq( |
|
| 557 | - 'spip_articles', |
|
| 558 | - ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 559 | - 'id_article=' . intval($id_article) |
|
| 560 | - ); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - if ($GLOBALS['meta']['multi_rubriques'] == 'oui') { |
|
| 564 | - $langues = calculer_langues_utilisees(); |
|
| 565 | - ecrire_meta('langues_utilisees', $langues); |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 569 | - pipeline('trig_calculer_langues_rubriques', ''); |
|
| 538 | + // rubriques (recursivite) |
|
| 539 | + sql_updateq( |
|
| 540 | + 'spip_rubriques', |
|
| 541 | + ['lang' => $GLOBALS['meta']['langue_site'], 'langue_choisie' => 'non'], |
|
| 542 | + "id_parent=0 AND langue_choisie != 'oui'" |
|
| 543 | + ); |
|
| 544 | + while (calculer_langues_rubriques_etape()) { |
|
| 545 | + ; |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + // articles |
|
| 549 | + $s = sql_select( |
|
| 550 | + 'A.id_article AS id_article, R.lang AS lang', |
|
| 551 | + 'spip_articles AS A, spip_rubriques AS R', |
|
| 552 | + "A.id_rubrique = R.id_rubrique AND A.langue_choisie != 'oui' AND (length(A.lang)=0 OR length(R.lang)>0) AND R.lang<>A.lang" |
|
| 553 | + ); |
|
| 554 | + while ($row = sql_fetch($s)) { |
|
| 555 | + $id_article = $row['id_article']; |
|
| 556 | + sql_updateq( |
|
| 557 | + 'spip_articles', |
|
| 558 | + ['lang' => $row['lang'], 'langue_choisie' => 'non'], |
|
| 559 | + 'id_article=' . intval($id_article) |
|
| 560 | + ); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + if ($GLOBALS['meta']['multi_rubriques'] == 'oui') { |
|
| 564 | + $langues = calculer_langues_utilisees(); |
|
| 565 | + ecrire_meta('langues_utilisees', $langues); |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + // avertir les plugins qui peuvent faire leur mises a jour egalement |
|
| 569 | + pipeline('trig_calculer_langues_rubriques', ''); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | |
@@ -583,80 +583,80 @@ discard block |
||
| 583 | 583 | * Liste des langues utilisées séparées par des virgules |
| 584 | 584 | **/ |
| 585 | 585 | function calculer_langues_utilisees($serveur = '') { |
| 586 | - include_spip('public/interfaces'); |
|
| 587 | - include_spip('public/compiler'); |
|
| 588 | - include_spip('public/composer'); |
|
| 589 | - include_spip('public/phraser_html'); |
|
| 590 | - $langues = []; |
|
| 591 | - |
|
| 592 | - $langues[$GLOBALS['meta']['langue_site']] = 1; |
|
| 593 | - |
|
| 594 | - include_spip('base/objets'); |
|
| 595 | - $tables = lister_tables_objets_sql(); |
|
| 596 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 597 | - |
|
| 598 | - foreach (array_keys($tables) as $t) { |
|
| 599 | - $desc = $trouver_table($t, $serveur); |
|
| 600 | - // c'est une table avec des langues |
|
| 601 | - if ( |
|
| 602 | - $desc['exist'] |
|
| 603 | - and isset($desc['field']['lang']) |
|
| 604 | - and isset($desc['field']['langue_choisie']) |
|
| 605 | - ) { |
|
| 606 | - $boucle = new Boucle(); |
|
| 607 | - $boucle->show = $desc; |
|
| 608 | - $boucle->nom = 'calculer_langues_utilisees'; |
|
| 609 | - $boucle->id_boucle = $desc['table_objet']; |
|
| 610 | - $boucle->id_table = $desc['table_objet']; |
|
| 611 | - $boucle->primary = $desc['key']['PRIMARY KEY'] ?? ''; |
|
| 612 | - $boucle->sql_serveur = $serveur; |
|
| 613 | - $boucle->select[] = 'DISTINCT lang'; |
|
| 614 | - $boucle->from[$desc['table_objet']] = $t; |
|
| 615 | - $boucle->separateur[] = ','; |
|
| 616 | - $boucle->return = '$Pile[$SP][\'lang\']'; |
|
| 617 | - $boucle->iterateur = 'sql'; |
|
| 618 | - |
|
| 619 | - $boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php |
|
| 620 | - $boucle->descr['sourcefile'] = 'internal'; |
|
| 621 | - $boucle->descr['gram'] = 'html'; |
|
| 622 | - |
|
| 623 | - $boucle = pipeline('pre_boucle', $boucle); |
|
| 624 | - |
|
| 625 | - if ( |
|
| 626 | - isset($desc['statut']) |
|
| 627 | - and $desc['statut'] |
|
| 628 | - ) { |
|
| 629 | - $boucles = [ |
|
| 630 | - 'calculer_langues_utilisees' => $boucle, |
|
| 631 | - ]; |
|
| 632 | - // generer un nom de fonction "anonyme" unique |
|
| 633 | - do { |
|
| 634 | - $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax()); |
|
| 635 | - } while (function_exists($functionname)); |
|
| 636 | - $code = calculer_boucle('calculer_langues_utilisees', $boucles); |
|
| 637 | - $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code; |
|
| 638 | - $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();'; |
|
| 639 | - $res = ''; |
|
| 640 | - eval($code); |
|
| 641 | - $res = explode(',', $res); |
|
| 642 | - foreach ($res as $lang) { |
|
| 643 | - $langues[$lang] = 1; |
|
| 644 | - } |
|
| 645 | - } else { |
|
| 646 | - $res = sql_select(implode(',', $boucle->select), $boucle->from); |
|
| 647 | - while ($row = sql_fetch($res)) { |
|
| 648 | - $langues[$row['lang']] = 1; |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - $langues = array_filter(array_keys($langues)); |
|
| 655 | - sort($langues); |
|
| 656 | - $langues = join(',', $langues); |
|
| 657 | - spip_log("langues utilisees: $langues"); |
|
| 658 | - |
|
| 659 | - return $langues; |
|
| 586 | + include_spip('public/interfaces'); |
|
| 587 | + include_spip('public/compiler'); |
|
| 588 | + include_spip('public/composer'); |
|
| 589 | + include_spip('public/phraser_html'); |
|
| 590 | + $langues = []; |
|
| 591 | + |
|
| 592 | + $langues[$GLOBALS['meta']['langue_site']] = 1; |
|
| 593 | + |
|
| 594 | + include_spip('base/objets'); |
|
| 595 | + $tables = lister_tables_objets_sql(); |
|
| 596 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 597 | + |
|
| 598 | + foreach (array_keys($tables) as $t) { |
|
| 599 | + $desc = $trouver_table($t, $serveur); |
|
| 600 | + // c'est une table avec des langues |
|
| 601 | + if ( |
|
| 602 | + $desc['exist'] |
|
| 603 | + and isset($desc['field']['lang']) |
|
| 604 | + and isset($desc['field']['langue_choisie']) |
|
| 605 | + ) { |
|
| 606 | + $boucle = new Boucle(); |
|
| 607 | + $boucle->show = $desc; |
|
| 608 | + $boucle->nom = 'calculer_langues_utilisees'; |
|
| 609 | + $boucle->id_boucle = $desc['table_objet']; |
|
| 610 | + $boucle->id_table = $desc['table_objet']; |
|
| 611 | + $boucle->primary = $desc['key']['PRIMARY KEY'] ?? ''; |
|
| 612 | + $boucle->sql_serveur = $serveur; |
|
| 613 | + $boucle->select[] = 'DISTINCT lang'; |
|
| 614 | + $boucle->from[$desc['table_objet']] = $t; |
|
| 615 | + $boucle->separateur[] = ','; |
|
| 616 | + $boucle->return = '$Pile[$SP][\'lang\']'; |
|
| 617 | + $boucle->iterateur = 'sql'; |
|
| 618 | + |
|
| 619 | + $boucle->descr['nom'] = 'calculer_langues_utilisees'; // eviter notice php |
|
| 620 | + $boucle->descr['sourcefile'] = 'internal'; |
|
| 621 | + $boucle->descr['gram'] = 'html'; |
|
| 622 | + |
|
| 623 | + $boucle = pipeline('pre_boucle', $boucle); |
|
| 624 | + |
|
| 625 | + if ( |
|
| 626 | + isset($desc['statut']) |
|
| 627 | + and $desc['statut'] |
|
| 628 | + ) { |
|
| 629 | + $boucles = [ |
|
| 630 | + 'calculer_langues_utilisees' => $boucle, |
|
| 631 | + ]; |
|
| 632 | + // generer un nom de fonction "anonyme" unique |
|
| 633 | + do { |
|
| 634 | + $functionname = 'f_calculer_langues_utilisees_' . $boucle->id_table . '_' . time() . '_' . random_int(0, mt_getrandmax()); |
|
| 635 | + } while (function_exists($functionname)); |
|
| 636 | + $code = calculer_boucle('calculer_langues_utilisees', $boucles); |
|
| 637 | + $code = '$SP=0; $command=array();$command["connect"] = $connect = "' . $serveur . '"; $Pile=array(0=>array());' . "\n" . $code; |
|
| 638 | + $code = 'function ' . $functionname . '(){' . $code . '};$res = ' . $functionname . '();'; |
|
| 639 | + $res = ''; |
|
| 640 | + eval($code); |
|
| 641 | + $res = explode(',', $res); |
|
| 642 | + foreach ($res as $lang) { |
|
| 643 | + $langues[$lang] = 1; |
|
| 644 | + } |
|
| 645 | + } else { |
|
| 646 | + $res = sql_select(implode(',', $boucle->select), $boucle->from); |
|
| 647 | + while ($row = sql_fetch($res)) { |
|
| 648 | + $langues[$row['lang']] = 1; |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + $langues = array_filter(array_keys($langues)); |
|
| 655 | + sort($langues); |
|
| 656 | + $langues = join(',', $langues); |
|
| 657 | + spip_log("langues utilisees: $langues"); |
|
| 658 | + |
|
| 659 | + return $langues; |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | /** |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | * incluant les rubriques noeuds et toutes leurs descendances |
| 674 | 674 | */ |
| 675 | 675 | function calcul_branche_in($id) { |
| 676 | - $calcul_branche_in = charger_fonction('calcul_branche_in', 'inc'); |
|
| 676 | + $calcul_branche_in = charger_fonction('calcul_branche_in', 'inc'); |
|
| 677 | 677 | |
| 678 | - return $calcul_branche_in($id); |
|
| 678 | + return $calcul_branche_in($id); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
@@ -693,9 +693,9 @@ discard block |
||
| 693 | 693 | * incluant les rubriques transmises et toutes leurs parentées |
| 694 | 694 | */ |
| 695 | 695 | function calcul_hierarchie_in($id, $tout = true) { |
| 696 | - $calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc'); |
|
| 696 | + $calcul_hierarchie_in = charger_fonction('calcul_hierarchie_in', 'inc'); |
|
| 697 | 697 | |
| 698 | - return $calcul_hierarchie_in($id, $tout); |
|
| 698 | + return $calcul_hierarchie_in($id, $tout); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | |
@@ -716,40 +716,40 @@ discard block |
||
| 716 | 716 | * incluant les rubriques noeuds et toutes leurs descendances |
| 717 | 717 | */ |
| 718 | 718 | function inc_calcul_branche_in_dist($id) { |
| 719 | - static $b = []; |
|
| 720 | - |
|
| 721 | - // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 722 | - if (!is_array($id)) { |
|
| 723 | - $id = explode(',', $id); |
|
| 724 | - } |
|
| 725 | - $id = join(',', array_map('intval', $id)); |
|
| 726 | - if (isset($b[$id])) { |
|
| 727 | - return $b[$id]; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - // Notre branche commence par la rubrique de depart |
|
| 731 | - $branche = $r = $id; |
|
| 732 | - |
|
| 733 | - // On ajoute une generation (les filles de la generation precedente) |
|
| 734 | - // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 735 | - $maxiter = 10000; |
|
| 736 | - while ( |
|
| 737 | - $maxiter-- and $filles = sql_allfetsel( |
|
| 738 | - 'id_rubrique', |
|
| 739 | - 'spip_rubriques', |
|
| 740 | - sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT') |
|
| 741 | - ) |
|
| 742 | - ) { |
|
| 743 | - $r = join(',', array_column($filles, 'id_rubrique')); |
|
| 744 | - $branche .= ',' . $r; |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 748 | - if (strlen($branche) < 10000) { |
|
| 749 | - $b[$id] = $branche; |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - return $branche; |
|
| 719 | + static $b = []; |
|
| 720 | + |
|
| 721 | + // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 722 | + if (!is_array($id)) { |
|
| 723 | + $id = explode(',', $id); |
|
| 724 | + } |
|
| 725 | + $id = join(',', array_map('intval', $id)); |
|
| 726 | + if (isset($b[$id])) { |
|
| 727 | + return $b[$id]; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + // Notre branche commence par la rubrique de depart |
|
| 731 | + $branche = $r = $id; |
|
| 732 | + |
|
| 733 | + // On ajoute une generation (les filles de la generation precedente) |
|
| 734 | + // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 735 | + $maxiter = 10000; |
|
| 736 | + while ( |
|
| 737 | + $maxiter-- and $filles = sql_allfetsel( |
|
| 738 | + 'id_rubrique', |
|
| 739 | + 'spip_rubriques', |
|
| 740 | + sql_in('id_parent', $r) . ' AND ' . sql_in('id_rubrique', $r, 'NOT') |
|
| 741 | + ) |
|
| 742 | + ) { |
|
| 743 | + $r = join(',', array_column($filles, 'id_rubrique')); |
|
| 744 | + $branche .= ',' . $r; |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 748 | + if (strlen($branche) < 10000) { |
|
| 749 | + $b[$id] = $branche; |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + return $branche; |
|
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | |
@@ -771,45 +771,45 @@ discard block |
||
| 771 | 771 | * incluant les rubriques transmises et toutes leurs parentées |
| 772 | 772 | */ |
| 773 | 773 | function inc_calcul_hierarchie_in_dist($id, $tout = true) { |
| 774 | - static $b = []; |
|
| 775 | - |
|
| 776 | - // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 777 | - if (!is_array($id)) { |
|
| 778 | - $id = explode(',', $id); |
|
| 779 | - } |
|
| 780 | - $id = join(',', array_map('intval', $id)); |
|
| 781 | - |
|
| 782 | - if (isset($b[$id])) { |
|
| 783 | - // Notre branche commence par la rubrique de depart si $tout=true |
|
| 784 | - return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id]; |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - $hier = ''; |
|
| 788 | - |
|
| 789 | - // On ajoute une generation (les filles de la generation precedente) |
|
| 790 | - // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 791 | - $ids_nouveaux_parents = $id; |
|
| 792 | - $maxiter = 10000; |
|
| 793 | - while ( |
|
| 794 | - $maxiter-- and $parents = sql_allfetsel( |
|
| 795 | - 'id_parent', |
|
| 796 | - 'spip_rubriques', |
|
| 797 | - sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT') |
|
| 798 | - ) |
|
| 799 | - ) { |
|
| 800 | - $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent')); |
|
| 801 | - $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : ''); |
|
| 802 | - } |
|
| 803 | - |
|
| 804 | - # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 805 | - if (strlen($hier) < 10000) { |
|
| 806 | - $b[$id] = $hier; |
|
| 807 | - } |
|
| 808 | - |
|
| 809 | - // Notre branche commence par la rubrique de depart si $tout=true |
|
| 810 | - $hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier; |
|
| 811 | - |
|
| 812 | - return $hier; |
|
| 774 | + static $b = []; |
|
| 775 | + |
|
| 776 | + // normaliser $id qui a pu arriver comme un array, comme un entier, ou comme une chaine NN,NN,NN |
|
| 777 | + if (!is_array($id)) { |
|
| 778 | + $id = explode(',', $id); |
|
| 779 | + } |
|
| 780 | + $id = join(',', array_map('intval', $id)); |
|
| 781 | + |
|
| 782 | + if (isset($b[$id])) { |
|
| 783 | + // Notre branche commence par la rubrique de depart si $tout=true |
|
| 784 | + return $tout ? (strlen($b[$id]) ? $b[$id] . ",$id" : $id) : $b[$id]; |
|
| 785 | + } |
|
| 786 | + |
|
| 787 | + $hier = ''; |
|
| 788 | + |
|
| 789 | + // On ajoute une generation (les filles de la generation precedente) |
|
| 790 | + // jusqu'a epuisement, en se protegeant des references circulaires |
|
| 791 | + $ids_nouveaux_parents = $id; |
|
| 792 | + $maxiter = 10000; |
|
| 793 | + while ( |
|
| 794 | + $maxiter-- and $parents = sql_allfetsel( |
|
| 795 | + 'id_parent', |
|
| 796 | + 'spip_rubriques', |
|
| 797 | + sql_in('id_rubrique', $ids_nouveaux_parents) . ' AND ' . sql_in('id_parent', $hier, 'NOT') |
|
| 798 | + ) |
|
| 799 | + ) { |
|
| 800 | + $ids_nouveaux_parents = join(',', array_column($parents, 'id_parent')); |
|
| 801 | + $hier = $ids_nouveaux_parents . (strlen($hier) ? ',' . $hier : ''); |
|
| 802 | + } |
|
| 803 | + |
|
| 804 | + # securite pour ne pas plomber la conso memoire sur les sites prolifiques |
|
| 805 | + if (strlen($hier) < 10000) { |
|
| 806 | + $b[$id] = $hier; |
|
| 807 | + } |
|
| 808 | + |
|
| 809 | + // Notre branche commence par la rubrique de depart si $tout=true |
|
| 810 | + $hier = $tout ? (strlen($hier) ? "$hier,$id" : $id) : $hier; |
|
| 811 | + |
|
| 812 | + return $hier; |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | |
@@ -827,47 +827,47 @@ discard block |
||
| 827 | 827 | * @return void |
| 828 | 828 | **/ |
| 829 | 829 | function calculer_prochain_postdate($check = false) { |
| 830 | - include_spip('base/abstract_sql'); |
|
| 831 | - if ($check) { |
|
| 832 | - $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 833 | - 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 834 | - |
|
| 835 | - $r = sql_select( |
|
| 836 | - 'DISTINCT A.id_rubrique AS id', |
|
| 837 | - 'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique', |
|
| 838 | - "R.statut != 'publie' AND A.statut='publie'$postdates" |
|
| 839 | - ); |
|
| 840 | - while ($row = sql_fetch($r)) { |
|
| 841 | - publier_branche_rubrique($row['id']); |
|
| 842 | - } |
|
| 843 | - |
|
| 844 | - pipeline('trig_calculer_prochain_postdate', ''); |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - $t = sql_fetsel( |
|
| 848 | - 'date', |
|
| 849 | - 'spip_articles', |
|
| 850 | - "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), |
|
| 851 | - '', |
|
| 852 | - 'date', |
|
| 853 | - '1' |
|
| 854 | - ); |
|
| 855 | - |
|
| 856 | - if ($t) { |
|
| 857 | - $t = $t['date']; |
|
| 858 | - if ( |
|
| 859 | - !isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 860 | - or $t <> $GLOBALS['meta']['date_prochain_postdate'] |
|
| 861 | - ) { |
|
| 862 | - ecrire_meta('date_prochain_postdate', strtotime($t)); |
|
| 863 | - ecrire_meta('derniere_modif', time()); |
|
| 864 | - } |
|
| 865 | - } else { |
|
| 866 | - effacer_meta('date_prochain_postdate'); |
|
| 867 | - ecrire_meta('derniere_modif', time()); |
|
| 868 | - } |
|
| 869 | - |
|
| 870 | - spip_log("prochain postdate: $t"); |
|
| 830 | + include_spip('base/abstract_sql'); |
|
| 831 | + if ($check) { |
|
| 832 | + $postdates = ($GLOBALS['meta']['post_dates'] == 'non') ? |
|
| 833 | + 'AND A.date <= ' . sql_quote(date('Y-m-d H:i:s')) : ''; |
|
| 834 | + |
|
| 835 | + $r = sql_select( |
|
| 836 | + 'DISTINCT A.id_rubrique AS id', |
|
| 837 | + 'spip_articles AS A LEFT JOIN spip_rubriques AS R ON A.id_rubrique=R.id_rubrique', |
|
| 838 | + "R.statut != 'publie' AND A.statut='publie'$postdates" |
|
| 839 | + ); |
|
| 840 | + while ($row = sql_fetch($r)) { |
|
| 841 | + publier_branche_rubrique($row['id']); |
|
| 842 | + } |
|
| 843 | + |
|
| 844 | + pipeline('trig_calculer_prochain_postdate', ''); |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + $t = sql_fetsel( |
|
| 848 | + 'date', |
|
| 849 | + 'spip_articles', |
|
| 850 | + "statut='publie' AND date > " . sql_quote(date('Y-m-d H:i:s')), |
|
| 851 | + '', |
|
| 852 | + 'date', |
|
| 853 | + '1' |
|
| 854 | + ); |
|
| 855 | + |
|
| 856 | + if ($t) { |
|
| 857 | + $t = $t['date']; |
|
| 858 | + if ( |
|
| 859 | + !isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 860 | + or $t <> $GLOBALS['meta']['date_prochain_postdate'] |
|
| 861 | + ) { |
|
| 862 | + ecrire_meta('date_prochain_postdate', strtotime($t)); |
|
| 863 | + ecrire_meta('derniere_modif', time()); |
|
| 864 | + } |
|
| 865 | + } else { |
|
| 866 | + effacer_meta('date_prochain_postdate'); |
|
| 867 | + ecrire_meta('derniere_modif', time()); |
|
| 868 | + } |
|
| 869 | + |
|
| 870 | + spip_log("prochain postdate: $t"); |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | /** |
@@ -892,62 +892,62 @@ discard block |
||
| 892 | 892 | */ |
| 893 | 893 | function creer_rubrique_nommee($titre, $id_parent = 0, $serveur = '') { |
| 894 | 894 | |
| 895 | - // eclater l'arborescence demandee |
|
| 896 | - // echapper les </multi> et autres balises fermantes html |
|
| 897 | - $titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre); |
|
| 898 | - $arbo = explode('/', preg_replace(',^/,', '', $titre)); |
|
| 899 | - include_spip('base/abstract_sql'); |
|
| 900 | - foreach ($arbo as $titre) { |
|
| 901 | - // retablir les </multi> et autres balises fermantes html |
|
| 902 | - $titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre); |
|
| 903 | - $r = sql_getfetsel( |
|
| 904 | - 'id_rubrique', |
|
| 905 | - 'spip_rubriques', |
|
| 906 | - 'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent), |
|
| 907 | - $groupby = [], |
|
| 908 | - $orderby = [], |
|
| 909 | - $limit = '', |
|
| 910 | - $having = [], |
|
| 911 | - $serveur |
|
| 912 | - ); |
|
| 913 | - if ($r !== null) { |
|
| 914 | - $id_parent = $r; |
|
| 915 | - } else { |
|
| 916 | - $id_rubrique = sql_insertq('spip_rubriques', [ |
|
| 917 | - 'titre' => $titre, |
|
| 918 | - 'id_parent' => $id_parent, |
|
| 919 | - 'statut' => 'prepa' |
|
| 920 | - ], $desc = [], $serveur); |
|
| 921 | - if ($id_parent > 0) { |
|
| 922 | - $data = sql_fetsel( |
|
| 923 | - 'id_secteur,lang', |
|
| 924 | - 'spip_rubriques', |
|
| 925 | - "id_rubrique=$id_parent", |
|
| 926 | - $groupby = [], |
|
| 927 | - $orderby = [], |
|
| 928 | - $limit = '', |
|
| 929 | - $having = [], |
|
| 930 | - $serveur |
|
| 931 | - ); |
|
| 932 | - $id_secteur = $data['id_secteur']; |
|
| 933 | - $lang = $data['lang']; |
|
| 934 | - } else { |
|
| 935 | - $id_secteur = $id_rubrique; |
|
| 936 | - $lang = $GLOBALS['meta']['langue_site']; |
|
| 937 | - } |
|
| 938 | - |
|
| 939 | - sql_updateq( |
|
| 940 | - 'spip_rubriques', |
|
| 941 | - ['id_secteur' => $id_secteur, 'lang' => $lang], |
|
| 942 | - 'id_rubrique=' . intval($id_rubrique), |
|
| 943 | - [], |
|
| 944 | - $serveur |
|
| 945 | - ); |
|
| 946 | - |
|
| 947 | - // pour la recursion |
|
| 948 | - $id_parent = $id_rubrique; |
|
| 949 | - } |
|
| 950 | - } |
|
| 951 | - |
|
| 952 | - return intval($id_parent); |
|
| 895 | + // eclater l'arborescence demandee |
|
| 896 | + // echapper les </multi> et autres balises fermantes html |
|
| 897 | + $titre = preg_replace(',</([a-z][^>]*)>,ims', "<@\\1>", $titre); |
|
| 898 | + $arbo = explode('/', preg_replace(',^/,', '', $titre)); |
|
| 899 | + include_spip('base/abstract_sql'); |
|
| 900 | + foreach ($arbo as $titre) { |
|
| 901 | + // retablir les </multi> et autres balises fermantes html |
|
| 902 | + $titre = preg_replace(',<@([a-z][^>]*)>,ims', "</\\1>", $titre); |
|
| 903 | + $r = sql_getfetsel( |
|
| 904 | + 'id_rubrique', |
|
| 905 | + 'spip_rubriques', |
|
| 906 | + 'titre = ' . sql_quote($titre) . ' AND id_parent=' . intval($id_parent), |
|
| 907 | + $groupby = [], |
|
| 908 | + $orderby = [], |
|
| 909 | + $limit = '', |
|
| 910 | + $having = [], |
|
| 911 | + $serveur |
|
| 912 | + ); |
|
| 913 | + if ($r !== null) { |
|
| 914 | + $id_parent = $r; |
|
| 915 | + } else { |
|
| 916 | + $id_rubrique = sql_insertq('spip_rubriques', [ |
|
| 917 | + 'titre' => $titre, |
|
| 918 | + 'id_parent' => $id_parent, |
|
| 919 | + 'statut' => 'prepa' |
|
| 920 | + ], $desc = [], $serveur); |
|
| 921 | + if ($id_parent > 0) { |
|
| 922 | + $data = sql_fetsel( |
|
| 923 | + 'id_secteur,lang', |
|
| 924 | + 'spip_rubriques', |
|
| 925 | + "id_rubrique=$id_parent", |
|
| 926 | + $groupby = [], |
|
| 927 | + $orderby = [], |
|
| 928 | + $limit = '', |
|
| 929 | + $having = [], |
|
| 930 | + $serveur |
|
| 931 | + ); |
|
| 932 | + $id_secteur = $data['id_secteur']; |
|
| 933 | + $lang = $data['lang']; |
|
| 934 | + } else { |
|
| 935 | + $id_secteur = $id_rubrique; |
|
| 936 | + $lang = $GLOBALS['meta']['langue_site']; |
|
| 937 | + } |
|
| 938 | + |
|
| 939 | + sql_updateq( |
|
| 940 | + 'spip_rubriques', |
|
| 941 | + ['id_secteur' => $id_secteur, 'lang' => $lang], |
|
| 942 | + 'id_rubrique=' . intval($id_rubrique), |
|
| 943 | + [], |
|
| 944 | + $serveur |
|
| 945 | + ); |
|
| 946 | + |
|
| 947 | + // pour la recursion |
|
| 948 | + $id_parent = $id_rubrique; |
|
| 949 | + } |
|
| 950 | + } |
|
| 951 | + |
|
| 952 | + return intval($id_parent); |
|
| 953 | 953 | } |
@@ -9,384 +9,384 @@ |
||
| 9 | 9 | |
| 10 | 10 | $GLOBALS['CHARSET']['translit'] = [ |
| 11 | 11 | // latin [fausse plage] |
| 12 | - 128 => 'EUR', |
|
| 13 | - 131 => 'f', |
|
| 14 | - 140 => 'OE', |
|
| 15 | - 147 => '\'\'', |
|
| 16 | - 148 => '\'\'', |
|
| 17 | - 153 => '(TM)', |
|
| 18 | - 156 => 'oe', |
|
| 19 | - 159 => 'Y', |
|
| 12 | + 128 => 'EUR', |
|
| 13 | + 131 => 'f', |
|
| 14 | + 140 => 'OE', |
|
| 15 | + 147 => '\'\'', |
|
| 16 | + 148 => '\'\'', |
|
| 17 | + 153 => '(TM)', |
|
| 18 | + 156 => 'oe', |
|
| 19 | + 159 => 'Y', |
|
| 20 | 20 | |
| 21 | 21 | // latin [legal] |
| 22 | - 160 => ' ', |
|
| 23 | - 161 => '!', |
|
| 24 | - 162 => 'c', |
|
| 25 | - 163 => 'L', |
|
| 26 | - 164 => 'O', |
|
| 27 | - 165 => 'yen', |
|
| 28 | - 166 => '|', |
|
| 29 | - 167 => 'p', |
|
| 30 | - 169 => '(c)', |
|
| 31 | - 171 => '<<', |
|
| 32 | - 172 => '-', |
|
| 33 | - 173 => '-', |
|
| 34 | - 174 => '(R)', |
|
| 35 | - 176 => 'o', |
|
| 36 | - 177 => '+-', |
|
| 37 | - 181 => 'mu', |
|
| 38 | - 182 => 'p', |
|
| 39 | - 183 => '.', |
|
| 40 | - 186 => 'o ', |
|
| 41 | - 187 => '>>', |
|
| 42 | - 191 => '?', |
|
| 43 | - 192 => 'A', |
|
| 44 | - 193 => 'A', |
|
| 45 | - 194 => 'A', |
|
| 46 | - 195 => 'A', |
|
| 47 | - 196 => 'A', |
|
| 48 | - 197 => 'A', |
|
| 49 | - 198 => 'AE', |
|
| 50 | - 199 => 'C', |
|
| 51 | - 200 => 'E', |
|
| 52 | - 201 => 'E', |
|
| 53 | - 202 => 'E', |
|
| 54 | - 203 => 'E', |
|
| 55 | - 204 => 'I', |
|
| 56 | - 205 => 'I', |
|
| 57 | - 206 => 'I', |
|
| 58 | - 207 => 'I', |
|
| 59 | - 209 => 'N', |
|
| 60 | - 210 => 'O', |
|
| 61 | - 211 => 'O', |
|
| 62 | - 212 => 'O', |
|
| 63 | - 213 => 'O', |
|
| 64 | - 214 => 'O', |
|
| 65 | - 216 => 'O', |
|
| 66 | - 217 => 'U', |
|
| 67 | - 218 => 'U', |
|
| 68 | - 219 => 'U', |
|
| 69 | - 220 => 'U', |
|
| 70 | - 223 => 'ss', |
|
| 71 | - 224 => 'a', |
|
| 72 | - 225 => 'a', |
|
| 73 | - 226 => 'a', |
|
| 74 | - 227 => 'a', |
|
| 75 | - 228 => 'a', |
|
| 76 | - 229 => 'a', |
|
| 77 | - 230 => 'ae', |
|
| 78 | - 231 => 'c', |
|
| 79 | - 232 => 'e', |
|
| 80 | - 233 => 'e', |
|
| 81 | - 234 => 'e', |
|
| 82 | - 235 => 'e', |
|
| 83 | - 236 => 'i', |
|
| 84 | - 237 => 'i', |
|
| 85 | - 238 => 'i', |
|
| 86 | - 239 => 'i', |
|
| 87 | - 241 => 'n', |
|
| 88 | - 242 => 'o', |
|
| 89 | - 243 => 'o', |
|
| 90 | - 244 => 'o', |
|
| 91 | - 245 => 'o', |
|
| 92 | - 246 => 'o', |
|
| 93 | - 248 => 'o', |
|
| 94 | - 249 => 'u', |
|
| 95 | - 250 => 'u', |
|
| 96 | - 251 => 'u', |
|
| 97 | - 252 => 'u', |
|
| 98 | - 255 => 'y', |
|
| 22 | + 160 => ' ', |
|
| 23 | + 161 => '!', |
|
| 24 | + 162 => 'c', |
|
| 25 | + 163 => 'L', |
|
| 26 | + 164 => 'O', |
|
| 27 | + 165 => 'yen', |
|
| 28 | + 166 => '|', |
|
| 29 | + 167 => 'p', |
|
| 30 | + 169 => '(c)', |
|
| 31 | + 171 => '<<', |
|
| 32 | + 172 => '-', |
|
| 33 | + 173 => '-', |
|
| 34 | + 174 => '(R)', |
|
| 35 | + 176 => 'o', |
|
| 36 | + 177 => '+-', |
|
| 37 | + 181 => 'mu', |
|
| 38 | + 182 => 'p', |
|
| 39 | + 183 => '.', |
|
| 40 | + 186 => 'o ', |
|
| 41 | + 187 => '>>', |
|
| 42 | + 191 => '?', |
|
| 43 | + 192 => 'A', |
|
| 44 | + 193 => 'A', |
|
| 45 | + 194 => 'A', |
|
| 46 | + 195 => 'A', |
|
| 47 | + 196 => 'A', |
|
| 48 | + 197 => 'A', |
|
| 49 | + 198 => 'AE', |
|
| 50 | + 199 => 'C', |
|
| 51 | + 200 => 'E', |
|
| 52 | + 201 => 'E', |
|
| 53 | + 202 => 'E', |
|
| 54 | + 203 => 'E', |
|
| 55 | + 204 => 'I', |
|
| 56 | + 205 => 'I', |
|
| 57 | + 206 => 'I', |
|
| 58 | + 207 => 'I', |
|
| 59 | + 209 => 'N', |
|
| 60 | + 210 => 'O', |
|
| 61 | + 211 => 'O', |
|
| 62 | + 212 => 'O', |
|
| 63 | + 213 => 'O', |
|
| 64 | + 214 => 'O', |
|
| 65 | + 216 => 'O', |
|
| 66 | + 217 => 'U', |
|
| 67 | + 218 => 'U', |
|
| 68 | + 219 => 'U', |
|
| 69 | + 220 => 'U', |
|
| 70 | + 223 => 'ss', |
|
| 71 | + 224 => 'a', |
|
| 72 | + 225 => 'a', |
|
| 73 | + 226 => 'a', |
|
| 74 | + 227 => 'a', |
|
| 75 | + 228 => 'a', |
|
| 76 | + 229 => 'a', |
|
| 77 | + 230 => 'ae', |
|
| 78 | + 231 => 'c', |
|
| 79 | + 232 => 'e', |
|
| 80 | + 233 => 'e', |
|
| 81 | + 234 => 'e', |
|
| 82 | + 235 => 'e', |
|
| 83 | + 236 => 'i', |
|
| 84 | + 237 => 'i', |
|
| 85 | + 238 => 'i', |
|
| 86 | + 239 => 'i', |
|
| 87 | + 241 => 'n', |
|
| 88 | + 242 => 'o', |
|
| 89 | + 243 => 'o', |
|
| 90 | + 244 => 'o', |
|
| 91 | + 245 => 'o', |
|
| 92 | + 246 => 'o', |
|
| 93 | + 248 => 'o', |
|
| 94 | + 249 => 'u', |
|
| 95 | + 250 => 'u', |
|
| 96 | + 251 => 'u', |
|
| 97 | + 252 => 'u', |
|
| 98 | + 255 => 'y', |
|
| 99 | 99 | |
| 100 | 100 | // turc |
| 101 | - 286 => 'G', |
|
| 102 | - 287 => 'g', |
|
| 103 | - 304 => 'I', |
|
| 104 | - 305 => 'i', |
|
| 101 | + 286 => 'G', |
|
| 102 | + 287 => 'g', |
|
| 103 | + 304 => 'I', |
|
| 104 | + 305 => 'i', |
|
| 105 | 105 | |
| 106 | 106 | // esperanto |
| 107 | - 264 => 'Cx', |
|
| 108 | - 265 => 'cx', |
|
| 109 | - 284 => 'Gx', |
|
| 110 | - 285 => 'gx', |
|
| 111 | - 292 => 'Hx', |
|
| 112 | - 293 => 'hx', |
|
| 113 | - 308 => 'Jx', |
|
| 114 | - 309 => 'jx', |
|
| 115 | - 348 => 'Sx', |
|
| 116 | - 349 => 'sx', |
|
| 117 | - 364 => 'Ux', |
|
| 118 | - 365 => 'ux', |
|
| 107 | + 264 => 'Cx', |
|
| 108 | + 265 => 'cx', |
|
| 109 | + 284 => 'Gx', |
|
| 110 | + 285 => 'gx', |
|
| 111 | + 292 => 'Hx', |
|
| 112 | + 293 => 'hx', |
|
| 113 | + 308 => 'Jx', |
|
| 114 | + 309 => 'jx', |
|
| 115 | + 348 => 'Sx', |
|
| 116 | + 349 => 'sx', |
|
| 117 | + 364 => 'Ux', |
|
| 118 | + 365 => 'ux', |
|
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | // latin2 [Czech] |
| 122 | - 283 => 'e', |
|
| 123 | - 353 => 's', |
|
| 124 | - 269 => 'c', |
|
| 125 | - 345 => 'r', |
|
| 126 | - 382 => 'z', |
|
| 127 | - 367 => 'u', |
|
| 128 | - 328 => 'n', |
|
| 129 | - 357 => 't', |
|
| 130 | - 271 => 'd', |
|
| 131 | - 449 => 'o', |
|
| 132 | - 282 => 'E', |
|
| 133 | - 352 => 'S', |
|
| 134 | - 268 => 'C', |
|
| 135 | - 344 => 'R', |
|
| 136 | - 381 => 'Z', |
|
| 137 | - 366 => 'U', |
|
| 138 | - 327 => 'N', |
|
| 139 | - 356 => 'T', |
|
| 140 | - 270 => 'D', |
|
| 141 | - 467 => 'O', |
|
| 122 | + 283 => 'e', |
|
| 123 | + 353 => 's', |
|
| 124 | + 269 => 'c', |
|
| 125 | + 345 => 'r', |
|
| 126 | + 382 => 'z', |
|
| 127 | + 367 => 'u', |
|
| 128 | + 328 => 'n', |
|
| 129 | + 357 => 't', |
|
| 130 | + 271 => 'd', |
|
| 131 | + 449 => 'o', |
|
| 132 | + 282 => 'E', |
|
| 133 | + 352 => 'S', |
|
| 134 | + 268 => 'C', |
|
| 135 | + 344 => 'R', |
|
| 136 | + 381 => 'Z', |
|
| 137 | + 366 => 'U', |
|
| 138 | + 327 => 'N', |
|
| 139 | + 356 => 'T', |
|
| 140 | + 270 => 'D', |
|
| 141 | + 467 => 'O', |
|
| 142 | 142 | |
| 143 | 143 | // francais |
| 144 | - 338 => 'OE', |
|
| 145 | - 339 => 'oe', |
|
| 146 | - 376 => 'Y', |
|
| 147 | - 402 => 'f', |
|
| 144 | + 338 => 'OE', |
|
| 145 | + 339 => 'oe', |
|
| 146 | + 376 => 'Y', |
|
| 147 | + 402 => 'f', |
|
| 148 | 148 | |
| 149 | 149 | //polskie |
| 150 | - 260 => 'A', |
|
| 151 | - 261 => 'a', |
|
| 152 | - 262 => 'C', |
|
| 153 | - 263 => 'c', |
|
| 154 | - 280 => 'E', |
|
| 155 | - 281 => 'e', |
|
| 156 | - 321 => 'L', |
|
| 157 | - 322 => 'l', |
|
| 158 | - 323 => 'N', |
|
| 159 | - 324 => 'n', |
|
| 160 | - 346 => 'S', |
|
| 161 | - 347 => 's', |
|
| 162 | - 377 => 'Z', |
|
| 163 | - 378 => 'z', |
|
| 164 | - 379 => 'Z', |
|
| 165 | - 380 => 'z', |
|
| 150 | + 260 => 'A', |
|
| 151 | + 261 => 'a', |
|
| 152 | + 262 => 'C', |
|
| 153 | + 263 => 'c', |
|
| 154 | + 280 => 'E', |
|
| 155 | + 281 => 'e', |
|
| 156 | + 321 => 'L', |
|
| 157 | + 322 => 'l', |
|
| 158 | + 323 => 'N', |
|
| 159 | + 324 => 'n', |
|
| 160 | + 346 => 'S', |
|
| 161 | + 347 => 's', |
|
| 162 | + 377 => 'Z', |
|
| 163 | + 378 => 'z', |
|
| 164 | + 379 => 'Z', |
|
| 165 | + 380 => 'z', |
|
| 166 | 166 | |
| 167 | 167 | //roumain |
| 168 | - 258 => 'A', |
|
| 169 | - 259 => 'a', |
|
| 170 | - 354 => 'T', |
|
| 171 | - 355 => 't', |
|
| 168 | + 258 => 'A', |
|
| 169 | + 259 => 'a', |
|
| 170 | + 354 => 'T', |
|
| 171 | + 355 => 't', |
|
| 172 | 172 | |
| 173 | 173 | //turc & roumain |
| 174 | - 350 => 'S', |
|
| 175 | - 351 => 's', |
|
| 174 | + 350 => 'S', |
|
| 175 | + 351 => 's', |
|
| 176 | 176 | |
| 177 | 177 | // cyrillique |
| 178 | - 1026 => 'D%', |
|
| 179 | - 1027 => 'G%', |
|
| 180 | - 8218 => '\'', |
|
| 181 | - 1107 => 'g%', |
|
| 182 | - 8222 => '"', |
|
| 183 | - 8230 => '...', |
|
| 184 | - 8224 => '/-', |
|
| 185 | - 8225 => '/=', |
|
| 186 | - 8364 => 'EUR', |
|
| 187 | - 8240 => '0/00', |
|
| 188 | - 1033 => 'LJ', |
|
| 189 | - 8249 => '<', |
|
| 190 | - 1034 => 'NJ', |
|
| 191 | - 1036 => 'KJ', |
|
| 192 | - 1035 => 'Ts', |
|
| 193 | - 1039 => 'DZ', |
|
| 194 | - 1106 => 'd%', |
|
| 195 | - 8216 => '`', |
|
| 196 | - 8217 => '\'', |
|
| 197 | - 8220 => '"', |
|
| 198 | - 8221 => '"', |
|
| 199 | - 8226 => ' o ', |
|
| 200 | - 8211 => '-', |
|
| 201 | - 8212 => '~', |
|
| 202 | - 8482 => '(TM)', |
|
| 203 | - 1113 => 'lj', |
|
| 204 | - 8250 => '>', |
|
| 205 | - 1114 => 'nj', |
|
| 206 | - 1116 => 'kj', |
|
| 207 | - 1115 => 'ts', |
|
| 208 | - 1119 => 'dz', |
|
| 209 | - 1038 => 'V%', |
|
| 210 | - 1118 => 'v%', |
|
| 211 | - 1032 => 'J%', |
|
| 212 | - 1168 => 'G3', |
|
| 213 | - 1025 => 'IO', |
|
| 214 | - 1028 => 'IE', |
|
| 215 | - 1031 => 'YI', |
|
| 216 | - 1030 => 'II', |
|
| 217 | - 1110 => 'ii', |
|
| 218 | - 1169 => 'g3', |
|
| 219 | - 1105 => 'io', |
|
| 220 | - 8470 => 'No.', |
|
| 221 | - 1108 => 'ie', |
|
| 222 | - 1112 => 'j%', |
|
| 223 | - 1029 => 'DS', |
|
| 224 | - 1109 => 'ds', |
|
| 225 | - 1111 => 'yi', |
|
| 226 | - 1040 => 'A', |
|
| 227 | - 1041 => 'B', |
|
| 228 | - 1042 => 'V', |
|
| 229 | - 1043 => 'G', |
|
| 230 | - 1044 => 'D', |
|
| 231 | - 1045 => 'E', |
|
| 232 | - 1046 => 'ZH', |
|
| 233 | - 1047 => 'Z', |
|
| 234 | - 1048 => 'I', |
|
| 235 | - 1049 => 'J', |
|
| 236 | - 1050 => 'K', |
|
| 237 | - 1051 => 'L', |
|
| 238 | - 1052 => 'M', |
|
| 239 | - 1053 => 'N', |
|
| 240 | - 1054 => 'O', |
|
| 241 | - 1055 => 'P', |
|
| 242 | - 1056 => 'R', |
|
| 243 | - 1057 => 'S', |
|
| 244 | - 1058 => 'T', |
|
| 245 | - 1059 => 'U', |
|
| 246 | - 1060 => 'F', |
|
| 247 | - 1061 => 'H', |
|
| 248 | - 1062 => 'C', |
|
| 249 | - 1063 => 'CH', |
|
| 250 | - 1064 => 'SH', |
|
| 251 | - 1065 => 'SCH', |
|
| 252 | - 1066 => '"', |
|
| 253 | - 1067 => 'Y', |
|
| 254 | - 1068 => '\'', |
|
| 255 | - 1069 => '`E', |
|
| 256 | - 1070 => 'YU', |
|
| 257 | - 1071 => 'YA', |
|
| 258 | - 1072 => 'a', |
|
| 259 | - 1073 => 'b', |
|
| 260 | - 1074 => 'v', |
|
| 261 | - 1075 => 'g', |
|
| 262 | - 1076 => 'd', |
|
| 263 | - 1077 => 'e', |
|
| 264 | - 1078 => 'zh', |
|
| 265 | - 1079 => 'z', |
|
| 266 | - 1080 => 'i', |
|
| 267 | - 1081 => 'j', |
|
| 268 | - 1082 => 'k', |
|
| 269 | - 1083 => 'l', |
|
| 270 | - 1084 => 'm', |
|
| 271 | - 1085 => 'n', |
|
| 272 | - 1086 => 'o', |
|
| 273 | - 1087 => 'p', |
|
| 274 | - 1088 => 'r', |
|
| 275 | - 1089 => 's', |
|
| 276 | - 1090 => 't', |
|
| 277 | - 1091 => 'u', |
|
| 278 | - 1092 => 'f', |
|
| 279 | - 1093 => 'h', |
|
| 280 | - 1094 => 'c', |
|
| 281 | - 1095 => 'ch', |
|
| 282 | - 1096 => 'sh', |
|
| 283 | - 1097 => 'sch', |
|
| 284 | - 1098 => '"', |
|
| 285 | - 1099 => 'y', |
|
| 286 | - 1100 => '\'', |
|
| 287 | - 1101 => '`e', |
|
| 288 | - 1102 => 'yu', |
|
| 289 | - 1103 => 'ya', |
|
| 178 | + 1026 => 'D%', |
|
| 179 | + 1027 => 'G%', |
|
| 180 | + 8218 => '\'', |
|
| 181 | + 1107 => 'g%', |
|
| 182 | + 8222 => '"', |
|
| 183 | + 8230 => '...', |
|
| 184 | + 8224 => '/-', |
|
| 185 | + 8225 => '/=', |
|
| 186 | + 8364 => 'EUR', |
|
| 187 | + 8240 => '0/00', |
|
| 188 | + 1033 => 'LJ', |
|
| 189 | + 8249 => '<', |
|
| 190 | + 1034 => 'NJ', |
|
| 191 | + 1036 => 'KJ', |
|
| 192 | + 1035 => 'Ts', |
|
| 193 | + 1039 => 'DZ', |
|
| 194 | + 1106 => 'd%', |
|
| 195 | + 8216 => '`', |
|
| 196 | + 8217 => '\'', |
|
| 197 | + 8220 => '"', |
|
| 198 | + 8221 => '"', |
|
| 199 | + 8226 => ' o ', |
|
| 200 | + 8211 => '-', |
|
| 201 | + 8212 => '~', |
|
| 202 | + 8482 => '(TM)', |
|
| 203 | + 1113 => 'lj', |
|
| 204 | + 8250 => '>', |
|
| 205 | + 1114 => 'nj', |
|
| 206 | + 1116 => 'kj', |
|
| 207 | + 1115 => 'ts', |
|
| 208 | + 1119 => 'dz', |
|
| 209 | + 1038 => 'V%', |
|
| 210 | + 1118 => 'v%', |
|
| 211 | + 1032 => 'J%', |
|
| 212 | + 1168 => 'G3', |
|
| 213 | + 1025 => 'IO', |
|
| 214 | + 1028 => 'IE', |
|
| 215 | + 1031 => 'YI', |
|
| 216 | + 1030 => 'II', |
|
| 217 | + 1110 => 'ii', |
|
| 218 | + 1169 => 'g3', |
|
| 219 | + 1105 => 'io', |
|
| 220 | + 8470 => 'No.', |
|
| 221 | + 1108 => 'ie', |
|
| 222 | + 1112 => 'j%', |
|
| 223 | + 1029 => 'DS', |
|
| 224 | + 1109 => 'ds', |
|
| 225 | + 1111 => 'yi', |
|
| 226 | + 1040 => 'A', |
|
| 227 | + 1041 => 'B', |
|
| 228 | + 1042 => 'V', |
|
| 229 | + 1043 => 'G', |
|
| 230 | + 1044 => 'D', |
|
| 231 | + 1045 => 'E', |
|
| 232 | + 1046 => 'ZH', |
|
| 233 | + 1047 => 'Z', |
|
| 234 | + 1048 => 'I', |
|
| 235 | + 1049 => 'J', |
|
| 236 | + 1050 => 'K', |
|
| 237 | + 1051 => 'L', |
|
| 238 | + 1052 => 'M', |
|
| 239 | + 1053 => 'N', |
|
| 240 | + 1054 => 'O', |
|
| 241 | + 1055 => 'P', |
|
| 242 | + 1056 => 'R', |
|
| 243 | + 1057 => 'S', |
|
| 244 | + 1058 => 'T', |
|
| 245 | + 1059 => 'U', |
|
| 246 | + 1060 => 'F', |
|
| 247 | + 1061 => 'H', |
|
| 248 | + 1062 => 'C', |
|
| 249 | + 1063 => 'CH', |
|
| 250 | + 1064 => 'SH', |
|
| 251 | + 1065 => 'SCH', |
|
| 252 | + 1066 => '"', |
|
| 253 | + 1067 => 'Y', |
|
| 254 | + 1068 => '\'', |
|
| 255 | + 1069 => '`E', |
|
| 256 | + 1070 => 'YU', |
|
| 257 | + 1071 => 'YA', |
|
| 258 | + 1072 => 'a', |
|
| 259 | + 1073 => 'b', |
|
| 260 | + 1074 => 'v', |
|
| 261 | + 1075 => 'g', |
|
| 262 | + 1076 => 'd', |
|
| 263 | + 1077 => 'e', |
|
| 264 | + 1078 => 'zh', |
|
| 265 | + 1079 => 'z', |
|
| 266 | + 1080 => 'i', |
|
| 267 | + 1081 => 'j', |
|
| 268 | + 1082 => 'k', |
|
| 269 | + 1083 => 'l', |
|
| 270 | + 1084 => 'm', |
|
| 271 | + 1085 => 'n', |
|
| 272 | + 1086 => 'o', |
|
| 273 | + 1087 => 'p', |
|
| 274 | + 1088 => 'r', |
|
| 275 | + 1089 => 's', |
|
| 276 | + 1090 => 't', |
|
| 277 | + 1091 => 'u', |
|
| 278 | + 1092 => 'f', |
|
| 279 | + 1093 => 'h', |
|
| 280 | + 1094 => 'c', |
|
| 281 | + 1095 => 'ch', |
|
| 282 | + 1096 => 'sh', |
|
| 283 | + 1097 => 'sch', |
|
| 284 | + 1098 => '"', |
|
| 285 | + 1099 => 'y', |
|
| 286 | + 1100 => '\'', |
|
| 287 | + 1101 => '`e', |
|
| 288 | + 1102 => 'yu', |
|
| 289 | + 1103 => 'ya', |
|
| 290 | 290 | |
| 291 | 291 | // vietnamien en translitteration de base |
| 292 | - 7843 => 'a', |
|
| 293 | - 7841 => 'a', |
|
| 294 | - 7845 => 'a', |
|
| 295 | - 7847 => 'a', |
|
| 296 | - 7849 => 'a', |
|
| 297 | - 7851 => 'a', |
|
| 298 | - 7853 => 'a', |
|
| 299 | - 7855 => 'a', |
|
| 300 | - 7857 => 'a', |
|
| 301 | - 7859 => 'a', |
|
| 302 | - 7861 => 'a', |
|
| 303 | - 7863 => 'a', |
|
| 304 | - 7842 => 'A', |
|
| 305 | - 7840 => 'A', |
|
| 306 | - 7844 => 'A', |
|
| 307 | - 7846 => 'A', |
|
| 308 | - 7848 => 'A', |
|
| 309 | - 7850 => 'A', |
|
| 310 | - 7852 => 'A', |
|
| 311 | - 7854 => 'A', |
|
| 312 | - 7856 => 'A', |
|
| 313 | - 7858 => 'A', |
|
| 314 | - 7860 => 'A', |
|
| 315 | - 7862 => 'A', |
|
| 316 | - 7867 => 'e', |
|
| 317 | - 7869 => 'e', |
|
| 318 | - 7865 => 'e', |
|
| 319 | - 7871 => 'e', |
|
| 320 | - 7873 => 'e', |
|
| 321 | - 7875 => 'e', |
|
| 322 | - 7877 => 'e', |
|
| 323 | - 7879 => 'e', |
|
| 324 | - 7866 => 'E', |
|
| 325 | - 7868 => 'E', |
|
| 326 | - 7864 => 'E', |
|
| 327 | - 7870 => 'E', |
|
| 328 | - 7872 => 'E', |
|
| 329 | - 7874 => 'E', |
|
| 330 | - 7876 => 'E', |
|
| 331 | - 7878 => 'E', |
|
| 332 | - 7881 => 'i', |
|
| 333 | - 7883 => 'i', |
|
| 334 | - 7880 => 'I', |
|
| 335 | - 7882 => 'I', |
|
| 336 | - 7887 => 'o', |
|
| 337 | - 7885 => 'o', |
|
| 338 | - 7889 => 'o', |
|
| 339 | - 7891 => 'o', |
|
| 340 | - 7893 => 'o', |
|
| 341 | - 7895 => 'o', |
|
| 342 | - 7897 => 'o', |
|
| 343 | - 417 => 'o', |
|
| 344 | - 7899 => 'o', |
|
| 345 | - 7901 => 'o', |
|
| 346 | - 7903 => 'o', |
|
| 347 | - 7905 => 'o', |
|
| 348 | - 7907 => 'o', |
|
| 349 | - 7886 => 'O', |
|
| 350 | - 7884 => 'O', |
|
| 351 | - 7888 => 'O', |
|
| 352 | - 7890 => 'O', |
|
| 353 | - 7892 => 'O', |
|
| 354 | - 7894 => 'O', |
|
| 355 | - 7896 => 'O', |
|
| 356 | - 416 => 'O', |
|
| 357 | - 7898 => 'O', |
|
| 358 | - 7900 => 'O', |
|
| 359 | - 7902 => 'O', |
|
| 360 | - 7904 => 'O', |
|
| 361 | - 7906 => 'O', |
|
| 362 | - 7911 => 'u', |
|
| 363 | - 361 => 'u', |
|
| 364 | - 7909 => 'u', |
|
| 365 | - 432 => 'u', |
|
| 366 | - 7913 => 'u', |
|
| 367 | - 7915 => 'u', |
|
| 368 | - 7917 => 'u', |
|
| 369 | - 7919 => 'u', |
|
| 370 | - 7921 => 'u', |
|
| 371 | - 7910 => 'U', |
|
| 372 | - 360 => 'U', |
|
| 373 | - 7908 => 'U', |
|
| 374 | - 431 => 'U', |
|
| 375 | - 7912 => 'U', |
|
| 376 | - 7914 => 'U', |
|
| 377 | - 7916 => 'U', |
|
| 378 | - 7918 => 'U', |
|
| 379 | - 7920 => 'U', |
|
| 380 | - 253 => 'y', |
|
| 381 | - 7923 => 'y', |
|
| 382 | - 7927 => 'y', |
|
| 383 | - 7929 => 'y', |
|
| 384 | - 7925 => 'y', |
|
| 385 | - 221 => 'Y', |
|
| 386 | - 7922 => 'Y', |
|
| 387 | - 7926 => 'Y', |
|
| 388 | - 7928 => 'Y', |
|
| 389 | - 7924 => 'Y', |
|
| 390 | - 273 => 'd' |
|
| 292 | + 7843 => 'a', |
|
| 293 | + 7841 => 'a', |
|
| 294 | + 7845 => 'a', |
|
| 295 | + 7847 => 'a', |
|
| 296 | + 7849 => 'a', |
|
| 297 | + 7851 => 'a', |
|
| 298 | + 7853 => 'a', |
|
| 299 | + 7855 => 'a', |
|
| 300 | + 7857 => 'a', |
|
| 301 | + 7859 => 'a', |
|
| 302 | + 7861 => 'a', |
|
| 303 | + 7863 => 'a', |
|
| 304 | + 7842 => 'A', |
|
| 305 | + 7840 => 'A', |
|
| 306 | + 7844 => 'A', |
|
| 307 | + 7846 => 'A', |
|
| 308 | + 7848 => 'A', |
|
| 309 | + 7850 => 'A', |
|
| 310 | + 7852 => 'A', |
|
| 311 | + 7854 => 'A', |
|
| 312 | + 7856 => 'A', |
|
| 313 | + 7858 => 'A', |
|
| 314 | + 7860 => 'A', |
|
| 315 | + 7862 => 'A', |
|
| 316 | + 7867 => 'e', |
|
| 317 | + 7869 => 'e', |
|
| 318 | + 7865 => 'e', |
|
| 319 | + 7871 => 'e', |
|
| 320 | + 7873 => 'e', |
|
| 321 | + 7875 => 'e', |
|
| 322 | + 7877 => 'e', |
|
| 323 | + 7879 => 'e', |
|
| 324 | + 7866 => 'E', |
|
| 325 | + 7868 => 'E', |
|
| 326 | + 7864 => 'E', |
|
| 327 | + 7870 => 'E', |
|
| 328 | + 7872 => 'E', |
|
| 329 | + 7874 => 'E', |
|
| 330 | + 7876 => 'E', |
|
| 331 | + 7878 => 'E', |
|
| 332 | + 7881 => 'i', |
|
| 333 | + 7883 => 'i', |
|
| 334 | + 7880 => 'I', |
|
| 335 | + 7882 => 'I', |
|
| 336 | + 7887 => 'o', |
|
| 337 | + 7885 => 'o', |
|
| 338 | + 7889 => 'o', |
|
| 339 | + 7891 => 'o', |
|
| 340 | + 7893 => 'o', |
|
| 341 | + 7895 => 'o', |
|
| 342 | + 7897 => 'o', |
|
| 343 | + 417 => 'o', |
|
| 344 | + 7899 => 'o', |
|
| 345 | + 7901 => 'o', |
|
| 346 | + 7903 => 'o', |
|
| 347 | + 7905 => 'o', |
|
| 348 | + 7907 => 'o', |
|
| 349 | + 7886 => 'O', |
|
| 350 | + 7884 => 'O', |
|
| 351 | + 7888 => 'O', |
|
| 352 | + 7890 => 'O', |
|
| 353 | + 7892 => 'O', |
|
| 354 | + 7894 => 'O', |
|
| 355 | + 7896 => 'O', |
|
| 356 | + 416 => 'O', |
|
| 357 | + 7898 => 'O', |
|
| 358 | + 7900 => 'O', |
|
| 359 | + 7902 => 'O', |
|
| 360 | + 7904 => 'O', |
|
| 361 | + 7906 => 'O', |
|
| 362 | + 7911 => 'u', |
|
| 363 | + 361 => 'u', |
|
| 364 | + 7909 => 'u', |
|
| 365 | + 432 => 'u', |
|
| 366 | + 7913 => 'u', |
|
| 367 | + 7915 => 'u', |
|
| 368 | + 7917 => 'u', |
|
| 369 | + 7919 => 'u', |
|
| 370 | + 7921 => 'u', |
|
| 371 | + 7910 => 'U', |
|
| 372 | + 360 => 'U', |
|
| 373 | + 7908 => 'U', |
|
| 374 | + 431 => 'U', |
|
| 375 | + 7912 => 'U', |
|
| 376 | + 7914 => 'U', |
|
| 377 | + 7916 => 'U', |
|
| 378 | + 7918 => 'U', |
|
| 379 | + 7920 => 'U', |
|
| 380 | + 253 => 'y', |
|
| 381 | + 7923 => 'y', |
|
| 382 | + 7927 => 'y', |
|
| 383 | + 7929 => 'y', |
|
| 384 | + 7925 => 'y', |
|
| 385 | + 221 => 'Y', |
|
| 386 | + 7922 => 'Y', |
|
| 387 | + 7926 => 'Y', |
|
| 388 | + 7928 => 'Y', |
|
| 389 | + 7924 => 'Y', |
|
| 390 | + 273 => 'd' |
|
| 391 | 391 | |
| 392 | 392 | ]; |
@@ -4,123 +4,123 @@ |
||
| 4 | 4 | // ** ne pas modifier le fichier ** |
| 5 | 5 | |
| 6 | 6 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 7 | - return; |
|
| 7 | + return; |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | $GLOBALS[$GLOBALS['idx_lang']] = array( |
| 11 | 11 | |
| 12 | - // A |
|
| 13 | - 'accueil_site' => 'Startseite', |
|
| 14 | - 'article' => 'Artikel', |
|
| 15 | - 'articles' => 'Artikel', |
|
| 16 | - 'articles_auteur' => 'Artikel dieses Autors', |
|
| 17 | - 'articles_populaires' => 'Die beliebtesten Artikel', |
|
| 18 | - 'articles_rubrique' => 'Artikel dieser Rubrik', |
|
| 19 | - 'aucun_article' => 'Unter dieser Adresse gibt es keinen Artikel.', |
|
| 20 | - 'aucun_auteur' => 'Unter dieser Adresse gibt es keinen Autor.', |
|
| 21 | - 'aucun_site' => 'Unter dieser Adresse gibt es keien Website.', |
|
| 22 | - 'aucune_breve' => 'Unter dieser Adresse gibt es keine Meldung.', |
|
| 23 | - 'aucune_rubrique' => 'Unter dieser Adresse gibt es keine Rubrik.', |
|
| 24 | - 'auteur' => 'Autor', |
|
| 25 | - 'autres' => 'Andere', |
|
| 26 | - 'autres_breves' => 'Weitere Meldungen.', |
|
| 27 | - 'autres_groupes_mots_clefs' => 'Weitere Schlagwortgruppen', |
|
| 28 | - 'autres_sites' => 'Weitere Websites', |
|
| 29 | - |
|
| 30 | - // B |
|
| 31 | - 'bonjour' => 'Hallo', |
|
| 32 | - |
|
| 33 | - // C |
|
| 34 | - 'commenter_site' => 'Website kommentieren', |
|
| 35 | - 'contact' => 'Kontakt', |
|
| 36 | - 'copie_document_impossible' => 'Dokument kann nicht kopiert werden', |
|
| 37 | - |
|
| 38 | - // D |
|
| 39 | - 'date' => 'Datum', |
|
| 40 | - 'dernier_ajout' => 'Neuester Eintrag', |
|
| 41 | - 'dernieres_breves' => 'Neue Meldungen', |
|
| 42 | - 'derniers_articles' => 'Neueste Artikel', |
|
| 43 | - 'derniers_commentaires' => 'Neueste Kommentare', |
|
| 44 | - 'derniers_messages_forum' => 'Neue Forumsbeiträge', |
|
| 45 | - |
|
| 46 | - // E |
|
| 47 | - 'edition_mode_texte' => 'Im Textmodus bearbeiten ', |
|
| 48 | - 'en_reponse' => 'Antwort auf:', |
|
| 49 | - 'en_resume' => 'Als Zusammenfassung', |
|
| 50 | - 'envoyer_message' => 'Nachricht senden', |
|
| 51 | - 'espace_prive' => 'Redaktion', |
|
| 52 | - |
|
| 53 | - // F |
|
| 54 | - 'formats_acceptes' => 'Akzeptierte Formate: @formats@.', |
|
| 55 | - |
|
| 56 | - // H |
|
| 57 | - 'hierarchie_site' => 'Baumstruktur der Website', |
|
| 58 | - |
|
| 59 | - // J |
|
| 60 | - 'jours' => 'Tage', |
|
| 61 | - |
|
| 62 | - // L |
|
| 63 | - 'lien_connecter' => 'Login', |
|
| 64 | - |
|
| 65 | - // M |
|
| 66 | - 'meme_auteur' => 'Vom gleichen Autor', |
|
| 67 | - 'meme_rubrique' => 'In der gleichen Rubrik', |
|
| 68 | - 'memes_auteurs' => 'Von den gleichen Autoren', |
|
| 69 | - 'message' => 'Nachricht', |
|
| 70 | - 'messages_forum' => 'Nachrichten', |
|
| 71 | - 'messages_recents' => 'Neue Forumsbeiträge', |
|
| 72 | - 'mots_clef' => 'Schlagwort', |
|
| 73 | - 'mots_clefs' => 'Schlagworte', |
|
| 74 | - 'mots_clefs_meme_groupe' => 'Schlagworte der gleichen Kategorie', |
|
| 75 | - |
|
| 76 | - // N |
|
| 77 | - 'navigation' => 'Navigation', |
|
| 78 | - 'nom' => 'Name', |
|
| 79 | - 'nouveautes' => 'Neuigkeiten', |
|
| 80 | - 'nouveautes_web' => 'Neues im WWW', |
|
| 81 | - 'nouveaux_articles' => 'Neue Artikel', |
|
| 82 | - 'nouvelles_breves' => 'Neue Meldungen', |
|
| 83 | - |
|
| 84 | - // P |
|
| 85 | - 'page_precedente' => 'vorige Seite', |
|
| 86 | - 'page_suivante' => 'nächste Seite', |
|
| 87 | - 'par_auteur' => 'von ', |
|
| 88 | - 'participer_site' => 'Sie können bei dieser Website mitmachen, wenn Sie sich anmelden. Sie erhalten sofort eine E-Mail mit den Zugangsdaten zum Redaktionssystem.', |
|
| 89 | - 'plan_site' => 'Sitemap', |
|
| 90 | - 'popularite' => 'Beliebtheit', |
|
| 91 | - 'poster_message' => 'Nachricht senden', |
|
| 92 | - 'proposer_site' => 'Sie können in dieser Rubrik eine Seite vorschlagen :', |
|
| 93 | - |
|
| 94 | - // R |
|
| 95 | - 'repondre_article' => 'auf diesen Artikel antworten', |
|
| 96 | - 'repondre_breve' => 'auf diese Meldung antworten', |
|
| 97 | - 'resultats_recherche' => 'Suchergebnis(se)', |
|
| 98 | - 'retour_debut_forums' => 'Zurück zum Beginn des Forums', |
|
| 99 | - 'rss_abonnement' => 'Kopieren Sie die folgende URL in Ihren Feedreader:', |
|
| 100 | - 'rss_abonnement_titre' => 'Abonnieren', |
|
| 101 | - 'rss_abonnement_titre_page' => 'Abonnieren von', |
|
| 102 | - 'rss_explication' => 'Ein RSS-Feed sammelt Informationen über die Aktualisierungen einer Website. Er liefert den Inhalt von Einträgen oder Kommentaren oder einen Auszug daraus sowie einen Link zu den Vollversionen und einige andere Informationen. Der Feed ist dazu gedacht, von einem RSS-Aggregator (Feedreader) gelesen zu werden', |
|
| 103 | - 'rss_explication_titre' => 'Was ist ein RSS-Feed ?', |
|
| 104 | - 'rubrique' => 'Rubrik', |
|
| 105 | - 'rubriques' => 'Rubriken', |
|
| 106 | - |
|
| 107 | - // S |
|
| 108 | - 'signatures_petition' => 'Unterschrift', |
|
| 109 | - 'site_realise_avec_spip' => 'Realisiert mit SPIP', |
|
| 110 | - 'sites_web' => 'Websites', |
|
| 111 | - 'sous_rubriques' => 'Unterrubriken', |
|
| 112 | - 'spam' => 'SPAM', |
|
| 113 | - 'suite' => 'weiter', |
|
| 114 | - 'sur_web' => 'Im WWW', |
|
| 115 | - 'syndiquer_rubrique' => 'Diese Rubrik per RSS einbinden', |
|
| 116 | - 'syndiquer_site' => 'Die ganze Website mit RSS einbinden', |
|
| 117 | - |
|
| 118 | - // T |
|
| 119 | - 'texte_lettre_information' => 'Dies ist der Newsletter der Website ', |
|
| 120 | - 'texte_lettre_information_2' => 'Diese Mail informiert über die Neuerscheinungen der letzten', |
|
| 121 | - |
|
| 122 | - // V |
|
| 123 | - 'ver_imprimer' => 'Druckversion', |
|
| 124 | - 'voir_en_ligne' => 'Online ansehen', |
|
| 125 | - 'voir_squelette' => 'Layoutvorlage dieser Seite ansehen' |
|
| 12 | + // A |
|
| 13 | + 'accueil_site' => 'Startseite', |
|
| 14 | + 'article' => 'Artikel', |
|
| 15 | + 'articles' => 'Artikel', |
|
| 16 | + 'articles_auteur' => 'Artikel dieses Autors', |
|
| 17 | + 'articles_populaires' => 'Die beliebtesten Artikel', |
|
| 18 | + 'articles_rubrique' => 'Artikel dieser Rubrik', |
|
| 19 | + 'aucun_article' => 'Unter dieser Adresse gibt es keinen Artikel.', |
|
| 20 | + 'aucun_auteur' => 'Unter dieser Adresse gibt es keinen Autor.', |
|
| 21 | + 'aucun_site' => 'Unter dieser Adresse gibt es keien Website.', |
|
| 22 | + 'aucune_breve' => 'Unter dieser Adresse gibt es keine Meldung.', |
|
| 23 | + 'aucune_rubrique' => 'Unter dieser Adresse gibt es keine Rubrik.', |
|
| 24 | + 'auteur' => 'Autor', |
|
| 25 | + 'autres' => 'Andere', |
|
| 26 | + 'autres_breves' => 'Weitere Meldungen.', |
|
| 27 | + 'autres_groupes_mots_clefs' => 'Weitere Schlagwortgruppen', |
|
| 28 | + 'autres_sites' => 'Weitere Websites', |
|
| 29 | + |
|
| 30 | + // B |
|
| 31 | + 'bonjour' => 'Hallo', |
|
| 32 | + |
|
| 33 | + // C |
|
| 34 | + 'commenter_site' => 'Website kommentieren', |
|
| 35 | + 'contact' => 'Kontakt', |
|
| 36 | + 'copie_document_impossible' => 'Dokument kann nicht kopiert werden', |
|
| 37 | + |
|
| 38 | + // D |
|
| 39 | + 'date' => 'Datum', |
|
| 40 | + 'dernier_ajout' => 'Neuester Eintrag', |
|
| 41 | + 'dernieres_breves' => 'Neue Meldungen', |
|
| 42 | + 'derniers_articles' => 'Neueste Artikel', |
|
| 43 | + 'derniers_commentaires' => 'Neueste Kommentare', |
|
| 44 | + 'derniers_messages_forum' => 'Neue Forumsbeiträge', |
|
| 45 | + |
|
| 46 | + // E |
|
| 47 | + 'edition_mode_texte' => 'Im Textmodus bearbeiten ', |
|
| 48 | + 'en_reponse' => 'Antwort auf:', |
|
| 49 | + 'en_resume' => 'Als Zusammenfassung', |
|
| 50 | + 'envoyer_message' => 'Nachricht senden', |
|
| 51 | + 'espace_prive' => 'Redaktion', |
|
| 52 | + |
|
| 53 | + // F |
|
| 54 | + 'formats_acceptes' => 'Akzeptierte Formate: @formats@.', |
|
| 55 | + |
|
| 56 | + // H |
|
| 57 | + 'hierarchie_site' => 'Baumstruktur der Website', |
|
| 58 | + |
|
| 59 | + // J |
|
| 60 | + 'jours' => 'Tage', |
|
| 61 | + |
|
| 62 | + // L |
|
| 63 | + 'lien_connecter' => 'Login', |
|
| 64 | + |
|
| 65 | + // M |
|
| 66 | + 'meme_auteur' => 'Vom gleichen Autor', |
|
| 67 | + 'meme_rubrique' => 'In der gleichen Rubrik', |
|
| 68 | + 'memes_auteurs' => 'Von den gleichen Autoren', |
|
| 69 | + 'message' => 'Nachricht', |
|
| 70 | + 'messages_forum' => 'Nachrichten', |
|
| 71 | + 'messages_recents' => 'Neue Forumsbeiträge', |
|
| 72 | + 'mots_clef' => 'Schlagwort', |
|
| 73 | + 'mots_clefs' => 'Schlagworte', |
|
| 74 | + 'mots_clefs_meme_groupe' => 'Schlagworte der gleichen Kategorie', |
|
| 75 | + |
|
| 76 | + // N |
|
| 77 | + 'navigation' => 'Navigation', |
|
| 78 | + 'nom' => 'Name', |
|
| 79 | + 'nouveautes' => 'Neuigkeiten', |
|
| 80 | + 'nouveautes_web' => 'Neues im WWW', |
|
| 81 | + 'nouveaux_articles' => 'Neue Artikel', |
|
| 82 | + 'nouvelles_breves' => 'Neue Meldungen', |
|
| 83 | + |
|
| 84 | + // P |
|
| 85 | + 'page_precedente' => 'vorige Seite', |
|
| 86 | + 'page_suivante' => 'nächste Seite', |
|
| 87 | + 'par_auteur' => 'von ', |
|
| 88 | + 'participer_site' => 'Sie können bei dieser Website mitmachen, wenn Sie sich anmelden. Sie erhalten sofort eine E-Mail mit den Zugangsdaten zum Redaktionssystem.', |
|
| 89 | + 'plan_site' => 'Sitemap', |
|
| 90 | + 'popularite' => 'Beliebtheit', |
|
| 91 | + 'poster_message' => 'Nachricht senden', |
|
| 92 | + 'proposer_site' => 'Sie können in dieser Rubrik eine Seite vorschlagen :', |
|
| 93 | + |
|
| 94 | + // R |
|
| 95 | + 'repondre_article' => 'auf diesen Artikel antworten', |
|
| 96 | + 'repondre_breve' => 'auf diese Meldung antworten', |
|
| 97 | + 'resultats_recherche' => 'Suchergebnis(se)', |
|
| 98 | + 'retour_debut_forums' => 'Zurück zum Beginn des Forums', |
|
| 99 | + 'rss_abonnement' => 'Kopieren Sie die folgende URL in Ihren Feedreader:', |
|
| 100 | + 'rss_abonnement_titre' => 'Abonnieren', |
|
| 101 | + 'rss_abonnement_titre_page' => 'Abonnieren von', |
|
| 102 | + 'rss_explication' => 'Ein RSS-Feed sammelt Informationen über die Aktualisierungen einer Website. Er liefert den Inhalt von Einträgen oder Kommentaren oder einen Auszug daraus sowie einen Link zu den Vollversionen und einige andere Informationen. Der Feed ist dazu gedacht, von einem RSS-Aggregator (Feedreader) gelesen zu werden', |
|
| 103 | + 'rss_explication_titre' => 'Was ist ein RSS-Feed ?', |
|
| 104 | + 'rubrique' => 'Rubrik', |
|
| 105 | + 'rubriques' => 'Rubriken', |
|
| 106 | + |
|
| 107 | + // S |
|
| 108 | + 'signatures_petition' => 'Unterschrift', |
|
| 109 | + 'site_realise_avec_spip' => 'Realisiert mit SPIP', |
|
| 110 | + 'sites_web' => 'Websites', |
|
| 111 | + 'sous_rubriques' => 'Unterrubriken', |
|
| 112 | + 'spam' => 'SPAM', |
|
| 113 | + 'suite' => 'weiter', |
|
| 114 | + 'sur_web' => 'Im WWW', |
|
| 115 | + 'syndiquer_rubrique' => 'Diese Rubrik per RSS einbinden', |
|
| 116 | + 'syndiquer_site' => 'Die ganze Website mit RSS einbinden', |
|
| 117 | + |
|
| 118 | + // T |
|
| 119 | + 'texte_lettre_information' => 'Dies ist der Newsletter der Website ', |
|
| 120 | + 'texte_lettre_information_2' => 'Diese Mail informiert über die Neuerscheinungen der letzten', |
|
| 121 | + |
|
| 122 | + // V |
|
| 123 | + 'ver_imprimer' => 'Druckversion', |
|
| 124 | + 'voir_en_ligne' => 'Online ansehen', |
|
| 125 | + 'voir_squelette' => 'Layoutvorlage dieser Seite ansehen' |
|
| 126 | 126 | ); |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $pass_poivre = hash_hmac('sha256', $password_clair, $key); |
| 38 | 38 | return password_verify($pass_poivre, $password_hash); |
| 39 | 39 | } |
| 40 | - spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 40 | + spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer'._LOG_INFO_IMPORTANTE); |
|
| 41 | 41 | return false; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $pass_poivre = hash_hmac('sha256', $password_clair, $key); |
| 60 | 60 | return password_hash($pass_poivre, PASSWORD_DEFAULT); |
| 61 | 61 | } |
| 62 | - spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 62 | + spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer'._LOG_INFO_IMPORTANTE); |
|
| 63 | 63 | return null; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -13,49 +13,49 @@ |
||
| 13 | 13 | |
| 14 | 14 | /** Vérification et hachage de mot de passe */ |
| 15 | 15 | class Password { |
| 16 | - /** |
|
| 17 | - * verifier qu'un mot de passe en clair est correct a l'aide de son hash |
|
| 18 | - * |
|
| 19 | - * Le mot de passe est poivre via la cle secret_des_auth |
|
| 20 | - */ |
|
| 21 | - public static function verifier( |
|
| 22 | - #[\SensitiveParameter] |
|
| 23 | - string $password_clair, |
|
| 24 | - #[\SensitiveParameter] |
|
| 25 | - string $password_hash, |
|
| 26 | - #[\SensitiveParameter] |
|
| 27 | - ?string $key = null |
|
| 28 | - ): bool { |
|
| 29 | - $key ??= self::getDefaultKey(); |
|
| 30 | - if ($key) { |
|
| 31 | - $pass_poivre = hash_hmac('sha256', $password_clair, $key); |
|
| 32 | - return password_verify($pass_poivre, $password_hash); |
|
| 33 | - } |
|
| 34 | - spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 35 | - return false; |
|
| 36 | - } |
|
| 16 | + /** |
|
| 17 | + * verifier qu'un mot de passe en clair est correct a l'aide de son hash |
|
| 18 | + * |
|
| 19 | + * Le mot de passe est poivre via la cle secret_des_auth |
|
| 20 | + */ |
|
| 21 | + public static function verifier( |
|
| 22 | + #[\SensitiveParameter] |
|
| 23 | + string $password_clair, |
|
| 24 | + #[\SensitiveParameter] |
|
| 25 | + string $password_hash, |
|
| 26 | + #[\SensitiveParameter] |
|
| 27 | + ?string $key = null |
|
| 28 | + ): bool { |
|
| 29 | + $key ??= self::getDefaultKey(); |
|
| 30 | + if ($key) { |
|
| 31 | + $pass_poivre = hash_hmac('sha256', $password_clair, $key); |
|
| 32 | + return password_verify($pass_poivre, $password_hash); |
|
| 33 | + } |
|
| 34 | + spip_log('Aucune clé pour vérifier le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Calculer un hash salé du mot de passe |
|
| 40 | - */ |
|
| 41 | - public static function hacher( |
|
| 42 | - #[\SensitiveParameter] |
|
| 43 | - string $password_clair, |
|
| 44 | - #[\SensitiveParameter] |
|
| 45 | - ?string $key = null |
|
| 46 | - ): ?string { |
|
| 47 | - $key ??= self::getDefaultKey(); |
|
| 48 | - // ne pas fournir un hash errone si la cle nous manque |
|
| 49 | - if ($key) { |
|
| 50 | - $pass_poivre = hash_hmac('sha256', $password_clair, $key); |
|
| 51 | - return password_hash($pass_poivre, PASSWORD_DEFAULT); |
|
| 52 | - } |
|
| 53 | - spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 54 | - return null; |
|
| 55 | - } |
|
| 38 | + /** |
|
| 39 | + * Calculer un hash salé du mot de passe |
|
| 40 | + */ |
|
| 41 | + public static function hacher( |
|
| 42 | + #[\SensitiveParameter] |
|
| 43 | + string $password_clair, |
|
| 44 | + #[\SensitiveParameter] |
|
| 45 | + ?string $key = null |
|
| 46 | + ): ?string { |
|
| 47 | + $key ??= self::getDefaultKey(); |
|
| 48 | + // ne pas fournir un hash errone si la cle nous manque |
|
| 49 | + if ($key) { |
|
| 50 | + $pass_poivre = hash_hmac('sha256', $password_clair, $key); |
|
| 51 | + return password_hash($pass_poivre, PASSWORD_DEFAULT); |
|
| 52 | + } |
|
| 53 | + spip_log('Aucune clé pour chiffrer le mot de passe', 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 54 | + return null; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - private static function getDefaultKey(): ?string { |
|
| 58 | - $keys = SpipCles::instance(); |
|
| 59 | - return $keys->getSecretAuth(); |
|
| 60 | - } |
|
| 57 | + private static function getDefaultKey(): ?string { |
|
| 58 | + $keys = SpipCles::instance(); |
|
| 59 | + return $keys->getSecretAuth(); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | public function generate(string $name): string { |
| 31 | 31 | $key = Chiffrement::keygen(); |
| 32 | 32 | $this->keys[$name] = $key; |
| 33 | - spip_log("Création de la cle $name", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 33 | + spip_log("Création de la cle $name", 'chiffrer'._LOG_INFO_IMPORTANTE); |
|
| 34 | 34 | return $key; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -13,46 +13,46 @@ |
||
| 13 | 13 | |
| 14 | 14 | /** Conteneur de clés (chiffrement, authentification) */ |
| 15 | 15 | class Cles implements \Countable /* , ContainerInterface */ { |
| 16 | - public function __construct(private array $keys) { |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - public function has(string $name): bool { |
|
| 20 | - return array_key_exists($name, $this->keys); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - public function get(string $name): ?string { |
|
| 24 | - return $this->keys[$name] ?? null; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public function generate(string $name): string { |
|
| 28 | - $key = Chiffrement::keygen(); |
|
| 29 | - $this->keys[$name] = $key; |
|
| 30 | - spip_log("Création de la cle $name", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 31 | - return $key; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function set( |
|
| 35 | - string $name, |
|
| 36 | - #[\SensitiveParameter] |
|
| 37 | - string $key |
|
| 38 | - ): void { |
|
| 39 | - $this->keys[$name] = $key; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - public function delete(string $name): bool { |
|
| 43 | - if (isset($this->keys[$name])) { |
|
| 44 | - unset($this->keys[$name]); |
|
| 45 | - return true; |
|
| 46 | - }; |
|
| 47 | - return false; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - public function count(): int { |
|
| 51 | - return count($this->keys); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function toJson(): string { |
|
| 55 | - $json = array_map('base64_encode', $this->keys); |
|
| 56 | - return \json_encode($json); |
|
| 57 | - } |
|
| 16 | + public function __construct(private array $keys) { |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + public function has(string $name): bool { |
|
| 20 | + return array_key_exists($name, $this->keys); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + public function get(string $name): ?string { |
|
| 24 | + return $this->keys[$name] ?? null; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + public function generate(string $name): string { |
|
| 28 | + $key = Chiffrement::keygen(); |
|
| 29 | + $this->keys[$name] = $key; |
|
| 30 | + spip_log("Création de la cle $name", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 31 | + return $key; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function set( |
|
| 35 | + string $name, |
|
| 36 | + #[\SensitiveParameter] |
|
| 37 | + string $key |
|
| 38 | + ): void { |
|
| 39 | + $this->keys[$name] = $key; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + public function delete(string $name): bool { |
|
| 43 | + if (isset($this->keys[$name])) { |
|
| 44 | + unset($this->keys[$name]); |
|
| 45 | + return true; |
|
| 46 | + }; |
|
| 47 | + return false; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + public function count(): int { |
|
| 51 | + return count($this->keys); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function toJson(): string { |
|
| 55 | + $json = array_map('base64_encode', $this->keys); |
|
| 56 | + return \json_encode($json); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Queue |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | define('_JQ_SCHEDULED', 1); |
@@ -50,103 +50,103 @@ discard block |
||
| 50 | 50 | * id of job |
| 51 | 51 | */ |
| 52 | 52 | function queue_add_job( |
| 53 | - $function, |
|
| 54 | - $description, |
|
| 55 | - $arguments = [], |
|
| 56 | - $file = '', |
|
| 57 | - $no_duplicate = false, |
|
| 58 | - $time = 0, |
|
| 59 | - $priority = 0 |
|
| 53 | + $function, |
|
| 54 | + $description, |
|
| 55 | + $arguments = [], |
|
| 56 | + $file = '', |
|
| 57 | + $no_duplicate = false, |
|
| 58 | + $time = 0, |
|
| 59 | + $priority = 0 |
|
| 60 | 60 | ) { |
| 61 | - include_spip('base/abstract_sql'); |
|
| 62 | - |
|
| 63 | - // cas pourri de ecrire/action/editer_site avec l'option reload=oui |
|
| 64 | - if (defined('_GENIE_SYNDIC_NOW')) { |
|
| 65 | - $arguments['id_syndic'] = _GENIE_SYNDIC_NOW; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - // serialiser les arguments |
|
| 69 | - $arguments = serialize($arguments); |
|
| 70 | - $md5args = md5($arguments); |
|
| 71 | - |
|
| 72 | - // si pas de date programee, des que possible |
|
| 73 | - $duplicate_where = 'status=' . intval(_JQ_SCHEDULED) . ' AND '; |
|
| 74 | - if (!$time) { |
|
| 75 | - $time = time(); |
|
| 76 | - $duplicate_where = ''; // ne pas dupliquer si deja le meme job en cours d'execution |
|
| 77 | - } |
|
| 78 | - $date = date('Y-m-d H:i:s', $time); |
|
| 79 | - |
|
| 80 | - $set_job = [ |
|
| 81 | - 'fonction' => $function, |
|
| 82 | - 'descriptif' => $description, |
|
| 83 | - 'args' => $arguments, |
|
| 84 | - 'md5args' => $md5args, |
|
| 85 | - 'inclure' => $file, |
|
| 86 | - 'priorite' => max(-10, min(10, intval($priority))), |
|
| 87 | - 'date' => $date, |
|
| 88 | - 'status' => _JQ_SCHEDULED, |
|
| 89 | - ]; |
|
| 90 | - // si option ne pas dupliquer, regarder si la fonction existe deja |
|
| 91 | - // avec les memes args et file |
|
| 92 | - if ( |
|
| 93 | - $no_duplicate |
|
| 94 | - and |
|
| 95 | - $id_job = sql_getfetsel( |
|
| 96 | - 'id_job', |
|
| 97 | - 'spip_jobs', |
|
| 98 | - $duplicate_where = |
|
| 99 | - $duplicate_where . 'fonction=' . sql_quote($function) |
|
| 100 | - . (($no_duplicate === 'function_only') ? '' : |
|
| 101 | - ' AND md5args=' . sql_quote($md5args) . ' AND inclure=' . sql_quote($file)) |
|
| 102 | - ) |
|
| 103 | - ) { |
|
| 104 | - return $id_job; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - $id_job = sql_insertq('spip_jobs', $set_job); |
|
| 108 | - // en cas de concurrence, deux process peuvent arriver jusqu'ici en parallele |
|
| 109 | - // avec le meme job unique a inserer. Dans ce cas, celui qui a eu l'id le plus grand |
|
| 110 | - // doit s'effacer |
|
| 111 | - if ( |
|
| 112 | - $no_duplicate |
|
| 113 | - and |
|
| 114 | - $id_prev = sql_getfetsel('id_job', 'spip_jobs', 'id_job<' . intval($id_job) . " AND $duplicate_where") |
|
| 115 | - ) { |
|
| 116 | - sql_delete('spip_jobs', 'id_job=' . intval($id_job)); |
|
| 117 | - |
|
| 118 | - return $id_prev; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // verifier la non duplication qui peut etre problematique en cas de concurence |
|
| 122 | - // il faut dans ce cas que seul le dernier ajoute se supprime ! |
|
| 123 | - |
|
| 124 | - // une option de debug pour verifier que les arguments en base sont bons |
|
| 125 | - // ie cas d'un char non acceptables sur certains type de champs |
|
| 126 | - // qui coupe la valeur |
|
| 127 | - if (defined('_JQ_INSERT_CHECK_ARGS') and $id_job) { |
|
| 128 | - $args = sql_getfetsel('args', 'spip_jobs', 'id_job=' . intval($id_job)); |
|
| 129 | - if ($args !== $arguments) { |
|
| 130 | - spip_log('arguments job errones / longueur ' . strlen($args) . ' vs ' . strlen($arguments) . ' / valeur : ' . var_export( |
|
| 131 | - $arguments, |
|
| 132 | - true |
|
| 133 | - ), 'queue'); |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - if ($id_job) { |
|
| 138 | - queue_update_next_job_time($time); |
|
| 139 | - } |
|
| 140 | - // si la mise en file d'attente du job echoue, |
|
| 141 | - // il ne faut pas perdre l'execution de la fonction |
|
| 142 | - // on la lance immediatement, c'est un fallback |
|
| 143 | - // sauf en cas d'upgrade necessaire (table spip_jobs inexistante) |
|
| 144 | - elseif ($GLOBALS['meta']['version_installee'] == $GLOBALS['spip_version_base']) { |
|
| 145 | - $set_job['id_job'] = 0; |
|
| 146 | - queue_start_job($set_job); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return $id_job; |
|
| 61 | + include_spip('base/abstract_sql'); |
|
| 62 | + |
|
| 63 | + // cas pourri de ecrire/action/editer_site avec l'option reload=oui |
|
| 64 | + if (defined('_GENIE_SYNDIC_NOW')) { |
|
| 65 | + $arguments['id_syndic'] = _GENIE_SYNDIC_NOW; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + // serialiser les arguments |
|
| 69 | + $arguments = serialize($arguments); |
|
| 70 | + $md5args = md5($arguments); |
|
| 71 | + |
|
| 72 | + // si pas de date programee, des que possible |
|
| 73 | + $duplicate_where = 'status=' . intval(_JQ_SCHEDULED) . ' AND '; |
|
| 74 | + if (!$time) { |
|
| 75 | + $time = time(); |
|
| 76 | + $duplicate_where = ''; // ne pas dupliquer si deja le meme job en cours d'execution |
|
| 77 | + } |
|
| 78 | + $date = date('Y-m-d H:i:s', $time); |
|
| 79 | + |
|
| 80 | + $set_job = [ |
|
| 81 | + 'fonction' => $function, |
|
| 82 | + 'descriptif' => $description, |
|
| 83 | + 'args' => $arguments, |
|
| 84 | + 'md5args' => $md5args, |
|
| 85 | + 'inclure' => $file, |
|
| 86 | + 'priorite' => max(-10, min(10, intval($priority))), |
|
| 87 | + 'date' => $date, |
|
| 88 | + 'status' => _JQ_SCHEDULED, |
|
| 89 | + ]; |
|
| 90 | + // si option ne pas dupliquer, regarder si la fonction existe deja |
|
| 91 | + // avec les memes args et file |
|
| 92 | + if ( |
|
| 93 | + $no_duplicate |
|
| 94 | + and |
|
| 95 | + $id_job = sql_getfetsel( |
|
| 96 | + 'id_job', |
|
| 97 | + 'spip_jobs', |
|
| 98 | + $duplicate_where = |
|
| 99 | + $duplicate_where . 'fonction=' . sql_quote($function) |
|
| 100 | + . (($no_duplicate === 'function_only') ? '' : |
|
| 101 | + ' AND md5args=' . sql_quote($md5args) . ' AND inclure=' . sql_quote($file)) |
|
| 102 | + ) |
|
| 103 | + ) { |
|
| 104 | + return $id_job; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + $id_job = sql_insertq('spip_jobs', $set_job); |
|
| 108 | + // en cas de concurrence, deux process peuvent arriver jusqu'ici en parallele |
|
| 109 | + // avec le meme job unique a inserer. Dans ce cas, celui qui a eu l'id le plus grand |
|
| 110 | + // doit s'effacer |
|
| 111 | + if ( |
|
| 112 | + $no_duplicate |
|
| 113 | + and |
|
| 114 | + $id_prev = sql_getfetsel('id_job', 'spip_jobs', 'id_job<' . intval($id_job) . " AND $duplicate_where") |
|
| 115 | + ) { |
|
| 116 | + sql_delete('spip_jobs', 'id_job=' . intval($id_job)); |
|
| 117 | + |
|
| 118 | + return $id_prev; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // verifier la non duplication qui peut etre problematique en cas de concurence |
|
| 122 | + // il faut dans ce cas que seul le dernier ajoute se supprime ! |
|
| 123 | + |
|
| 124 | + // une option de debug pour verifier que les arguments en base sont bons |
|
| 125 | + // ie cas d'un char non acceptables sur certains type de champs |
|
| 126 | + // qui coupe la valeur |
|
| 127 | + if (defined('_JQ_INSERT_CHECK_ARGS') and $id_job) { |
|
| 128 | + $args = sql_getfetsel('args', 'spip_jobs', 'id_job=' . intval($id_job)); |
|
| 129 | + if ($args !== $arguments) { |
|
| 130 | + spip_log('arguments job errones / longueur ' . strlen($args) . ' vs ' . strlen($arguments) . ' / valeur : ' . var_export( |
|
| 131 | + $arguments, |
|
| 132 | + true |
|
| 133 | + ), 'queue'); |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + if ($id_job) { |
|
| 138 | + queue_update_next_job_time($time); |
|
| 139 | + } |
|
| 140 | + // si la mise en file d'attente du job echoue, |
|
| 141 | + // il ne faut pas perdre l'execution de la fonction |
|
| 142 | + // on la lance immediatement, c'est un fallback |
|
| 143 | + // sauf en cas d'upgrade necessaire (table spip_jobs inexistante) |
|
| 144 | + elseif ($GLOBALS['meta']['version_installee'] == $GLOBALS['spip_version_base']) { |
|
| 145 | + $set_job['id_job'] = 0; |
|
| 146 | + queue_start_job($set_job); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return $id_job; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | * @return void |
| 156 | 156 | */ |
| 157 | 157 | function queue_purger() { |
| 158 | - include_spip('base/abstract_sql'); |
|
| 159 | - sql_delete('spip_jobs'); |
|
| 160 | - sql_delete('spip_jobs_liens', 'id_job NOT IN (' . sql_get_select('id_job', 'spip_jobs') . ')'); |
|
| 161 | - include_spip('inc/genie'); |
|
| 162 | - genie_queue_watch_dist(); |
|
| 158 | + include_spip('base/abstract_sql'); |
|
| 159 | + sql_delete('spip_jobs'); |
|
| 160 | + sql_delete('spip_jobs_liens', 'id_job NOT IN (' . sql_get_select('id_job', 'spip_jobs') . ')'); |
|
| 161 | + include_spip('inc/genie'); |
|
| 162 | + genie_queue_watch_dist(); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -170,25 +170,25 @@ discard block |
||
| 170 | 170 | * @return int|bool |
| 171 | 171 | */ |
| 172 | 172 | function queue_remove_job($id_job) { |
| 173 | - include_spip('base/abstract_sql'); |
|
| 174 | - |
|
| 175 | - if ( |
|
| 176 | - $row = sql_fetsel('fonction,inclure,date', 'spip_jobs', 'id_job=' . intval($id_job)) |
|
| 177 | - and $res = sql_delete('spip_jobs', 'id_job=' . intval($id_job)) |
|
| 178 | - ) { |
|
| 179 | - queue_unlink_job($id_job); |
|
| 180 | - // est-ce une tache cron qu'il faut relancer ? |
|
| 181 | - if ($periode = queue_is_cron_job($row['fonction'], $row['inclure'])) { |
|
| 182 | - // relancer avec les nouveaux arguments de temps |
|
| 183 | - include_spip('inc/genie'); |
|
| 184 | - // relancer avec la periode prevue |
|
| 185 | - queue_genie_replan_job($row['fonction'], $periode, strtotime($row['date'])); |
|
| 186 | - } |
|
| 187 | - queue_update_next_job_time(); |
|
| 188 | - return $res; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return false; |
|
| 173 | + include_spip('base/abstract_sql'); |
|
| 174 | + |
|
| 175 | + if ( |
|
| 176 | + $row = sql_fetsel('fonction,inclure,date', 'spip_jobs', 'id_job=' . intval($id_job)) |
|
| 177 | + and $res = sql_delete('spip_jobs', 'id_job=' . intval($id_job)) |
|
| 178 | + ) { |
|
| 179 | + queue_unlink_job($id_job); |
|
| 180 | + // est-ce une tache cron qu'il faut relancer ? |
|
| 181 | + if ($periode = queue_is_cron_job($row['fonction'], $row['inclure'])) { |
|
| 182 | + // relancer avec les nouveaux arguments de temps |
|
| 183 | + include_spip('inc/genie'); |
|
| 184 | + // relancer avec la periode prevue |
|
| 185 | + queue_genie_replan_job($row['fonction'], $periode, strtotime($row['date'])); |
|
| 186 | + } |
|
| 187 | + queue_update_next_job_time(); |
|
| 188 | + return $res; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return false; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -201,18 +201,18 @@ discard block |
||
| 201 | 201 | * ou un tableau composé de tableaux simples pour lieur plusieurs objets en une fois |
| 202 | 202 | */ |
| 203 | 203 | function queue_link_job($id_job, $objets) { |
| 204 | - include_spip('base/abstract_sql'); |
|
| 205 | - |
|
| 206 | - if (is_array($objets) and count($objets)) { |
|
| 207 | - if (is_array(reset($objets))) { |
|
| 208 | - foreach ($objets as $k => $o) { |
|
| 209 | - $objets[$k]['id_job'] = $id_job; |
|
| 210 | - } |
|
| 211 | - sql_insertq_multi('spip_jobs_liens', $objets); |
|
| 212 | - } else { |
|
| 213 | - sql_insertq('spip_jobs_liens', array_merge(['id_job' => $id_job], $objets)); |
|
| 214 | - } |
|
| 215 | - } |
|
| 204 | + include_spip('base/abstract_sql'); |
|
| 205 | + |
|
| 206 | + if (is_array($objets) and count($objets)) { |
|
| 207 | + if (is_array(reset($objets))) { |
|
| 208 | + foreach ($objets as $k => $o) { |
|
| 209 | + $objets[$k]['id_job'] = $id_job; |
|
| 210 | + } |
|
| 211 | + sql_insertq_multi('spip_jobs_liens', $objets); |
|
| 212 | + } else { |
|
| 213 | + sql_insertq('spip_jobs_liens', array_merge(['id_job' => $id_job], $objets)); |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * resultat du sql_delete |
| 225 | 225 | */ |
| 226 | 226 | function queue_unlink_job($id_job) { |
| 227 | - return sql_delete('spip_jobs_liens', 'id_job=' . intval($id_job)); |
|
| 227 | + return sql_delete('spip_jobs_liens', 'id_job=' . intval($id_job)); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -237,36 +237,36 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | function queue_start_job($row) { |
| 239 | 239 | |
| 240 | - // deserialiser les arguments |
|
| 241 | - $args = unserialize($row['args']); |
|
| 242 | - if (!is_array($args)) { |
|
| 243 | - spip_log('arguments job errones ' . var_export($row, true), 'queue'); |
|
| 244 | - $args = []; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - $fonction = $row['fonction']; |
|
| 248 | - if (strlen($inclure = trim($row['inclure']))) { |
|
| 249 | - if (substr($inclure, -1) == '/') { // c'est un chemin pour charger_fonction |
|
| 250 | - $f = charger_fonction($fonction, rtrim($inclure, '/'), false); |
|
| 251 | - if ($f) { |
|
| 252 | - $fonction = $f; |
|
| 253 | - } |
|
| 254 | - } else { |
|
| 255 | - include_spip($inclure); |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - if (!function_exists($fonction)) { |
|
| 260 | - spip_log("fonction $fonction ($inclure) inexistante " . var_export($row, true), 'queue'); |
|
| 261 | - |
|
| 262 | - return false; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - spip_log('queue [' . $row['id_job'] . "]: $fonction() start", 'queue'); |
|
| 266 | - $res = $fonction(...$args); |
|
| 267 | - spip_log('queue [' . $row['id_job'] . "]: $fonction() end", 'queue'); |
|
| 268 | - |
|
| 269 | - return $res; |
|
| 240 | + // deserialiser les arguments |
|
| 241 | + $args = unserialize($row['args']); |
|
| 242 | + if (!is_array($args)) { |
|
| 243 | + spip_log('arguments job errones ' . var_export($row, true), 'queue'); |
|
| 244 | + $args = []; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + $fonction = $row['fonction']; |
|
| 248 | + if (strlen($inclure = trim($row['inclure']))) { |
|
| 249 | + if (substr($inclure, -1) == '/') { // c'est un chemin pour charger_fonction |
|
| 250 | + $f = charger_fonction($fonction, rtrim($inclure, '/'), false); |
|
| 251 | + if ($f) { |
|
| 252 | + $fonction = $f; |
|
| 253 | + } |
|
| 254 | + } else { |
|
| 255 | + include_spip($inclure); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + if (!function_exists($fonction)) { |
|
| 260 | + spip_log("fonction $fonction ($inclure) inexistante " . var_export($row, true), 'queue'); |
|
| 261 | + |
|
| 262 | + return false; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + spip_log('queue [' . $row['id_job'] . "]: $fonction() start", 'queue'); |
|
| 266 | + $res = $fonction(...$args); |
|
| 267 | + spip_log('queue [' . $row['id_job'] . "]: $fonction() end", 'queue'); |
|
| 268 | + |
|
| 269 | + return $res; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -293,89 +293,89 @@ discard block |
||
| 293 | 293 | * - true : une planification a été faite. |
| 294 | 294 | */ |
| 295 | 295 | function queue_schedule($force_jobs = null) { |
| 296 | - $time = time(); |
|
| 297 | - if (defined('_DEBUG_BLOCK_QUEUE')) { |
|
| 298 | - spip_log('_DEBUG_BLOCK_QUEUE : schedule stop', 'jq' . _LOG_DEBUG); |
|
| 299 | - |
|
| 300 | - return; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - // rien a faire si le prochain job est encore dans le futur |
|
| 304 | - if (queue_sleep_time_to_next_job() > 0 and (!$force_jobs or !count($force_jobs))) { |
|
| 305 | - spip_log('queue_sleep_time_to_next_job', 'jq' . _LOG_DEBUG); |
|
| 306 | - |
|
| 307 | - return; |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - include_spip('base/abstract_sql'); |
|
| 311 | - // on ne peut rien faire si pas de connexion SQL |
|
| 312 | - if (!spip_connect()) { |
|
| 313 | - return false; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - if (!defined('_JQ_MAX_JOBS_TIME_TO_EXECUTE')) { |
|
| 317 | - $max_time = ini_get('max_execution_time') / 2; |
|
| 318 | - // valeur conservatrice si on a pas reussi a lire le max_execution_time |
|
| 319 | - if (!$max_time) { |
|
| 320 | - $max_time = 5; |
|
| 321 | - } |
|
| 322 | - define('_JQ_MAX_JOBS_TIME_TO_EXECUTE', min($max_time, 15)); // une valeur maxi en temps. |
|
| 323 | - } |
|
| 324 | - $end_time = $time + _JQ_MAX_JOBS_TIME_TO_EXECUTE; |
|
| 325 | - |
|
| 326 | - spip_log("JQ schedule $time / $end_time", 'jq' . _LOG_DEBUG); |
|
| 327 | - |
|
| 328 | - if (!defined('_JQ_MAX_JOBS_EXECUTE')) { |
|
| 329 | - define('_JQ_MAX_JOBS_EXECUTE', 200); |
|
| 330 | - } |
|
| 331 | - $nbj = 0; |
|
| 332 | - // attraper les jobs |
|
| 333 | - // dont la date est passee (echus en attente), |
|
| 334 | - // par ordre : |
|
| 335 | - // - de priorite |
|
| 336 | - // - de date |
|
| 337 | - // lorsqu'un job cron n'a pas fini, sa priorite est descendue |
|
| 338 | - // pour qu'il ne bloque pas les autres jobs en attente |
|
| 339 | - if (is_array($force_jobs) and count($force_jobs)) { |
|
| 340 | - $cond = 'status=' . intval(_JQ_SCHEDULED) . ' AND ' . sql_in('id_job', $force_jobs); |
|
| 341 | - } else { |
|
| 342 | - $now = date('Y-m-d H:i:s', $time); |
|
| 343 | - $cond = 'status=' . intval(_JQ_SCHEDULED) . ' AND date<=' . sql_quote($now); |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - register_shutdown_function('queue_error_handler'); // recuperer les erreurs auant que possible |
|
| 347 | - $res = sql_allfetsel('*', 'spip_jobs', $cond, '', 'priorite DESC,date', '0,' . (_JQ_MAX_JOBS_EXECUTE + 1)); |
|
| 348 | - do { |
|
| 349 | - if ($row = array_shift($res)) { |
|
| 350 | - $nbj++; |
|
| 351 | - // il faut un verrou, a base de sql_delete |
|
| 352 | - if (sql_delete('spip_jobs', 'id_job=' . intval($row['id_job']) . ' AND status=' . intval(_JQ_SCHEDULED))) { |
|
| 353 | - #spip_log("JQ schedule job ".$nbj." OK",'jq'); |
|
| 354 | - // on reinsert dans la base aussitot avec un status=_JQ_PENDING |
|
| 355 | - $row['status'] = _JQ_PENDING; |
|
| 356 | - $row['date'] = date('Y-m-d H:i:s', $time); |
|
| 357 | - sql_insertq('spip_jobs', $row); |
|
| 358 | - |
|
| 359 | - // on a la main sur le job : |
|
| 360 | - // l'executer |
|
| 361 | - $result = queue_start_job($row); |
|
| 362 | - |
|
| 363 | - $time = time(); |
|
| 364 | - queue_close_job($row, $time, $result); |
|
| 365 | - } |
|
| 366 | - } |
|
| 367 | - spip_log('JQ schedule job end time ' . $time, 'jq' . _LOG_DEBUG); |
|
| 368 | - } while ($nbj < _JQ_MAX_JOBS_EXECUTE and $row and $time < $end_time); |
|
| 369 | - spip_log('JQ schedule end time ' . time(), 'jq' . _LOG_DEBUG); |
|
| 370 | - |
|
| 371 | - if ($row = array_shift($res)) { |
|
| 372 | - queue_update_next_job_time(0); // on sait qu'il y a encore des jobs a lancer ASAP |
|
| 373 | - spip_log('JQ encore !', 'jq' . _LOG_DEBUG); |
|
| 374 | - } else { |
|
| 375 | - queue_update_next_job_time(); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - return true; |
|
| 296 | + $time = time(); |
|
| 297 | + if (defined('_DEBUG_BLOCK_QUEUE')) { |
|
| 298 | + spip_log('_DEBUG_BLOCK_QUEUE : schedule stop', 'jq' . _LOG_DEBUG); |
|
| 299 | + |
|
| 300 | + return; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + // rien a faire si le prochain job est encore dans le futur |
|
| 304 | + if (queue_sleep_time_to_next_job() > 0 and (!$force_jobs or !count($force_jobs))) { |
|
| 305 | + spip_log('queue_sleep_time_to_next_job', 'jq' . _LOG_DEBUG); |
|
| 306 | + |
|
| 307 | + return; |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + include_spip('base/abstract_sql'); |
|
| 311 | + // on ne peut rien faire si pas de connexion SQL |
|
| 312 | + if (!spip_connect()) { |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + if (!defined('_JQ_MAX_JOBS_TIME_TO_EXECUTE')) { |
|
| 317 | + $max_time = ini_get('max_execution_time') / 2; |
|
| 318 | + // valeur conservatrice si on a pas reussi a lire le max_execution_time |
|
| 319 | + if (!$max_time) { |
|
| 320 | + $max_time = 5; |
|
| 321 | + } |
|
| 322 | + define('_JQ_MAX_JOBS_TIME_TO_EXECUTE', min($max_time, 15)); // une valeur maxi en temps. |
|
| 323 | + } |
|
| 324 | + $end_time = $time + _JQ_MAX_JOBS_TIME_TO_EXECUTE; |
|
| 325 | + |
|
| 326 | + spip_log("JQ schedule $time / $end_time", 'jq' . _LOG_DEBUG); |
|
| 327 | + |
|
| 328 | + if (!defined('_JQ_MAX_JOBS_EXECUTE')) { |
|
| 329 | + define('_JQ_MAX_JOBS_EXECUTE', 200); |
|
| 330 | + } |
|
| 331 | + $nbj = 0; |
|
| 332 | + // attraper les jobs |
|
| 333 | + // dont la date est passee (echus en attente), |
|
| 334 | + // par ordre : |
|
| 335 | + // - de priorite |
|
| 336 | + // - de date |
|
| 337 | + // lorsqu'un job cron n'a pas fini, sa priorite est descendue |
|
| 338 | + // pour qu'il ne bloque pas les autres jobs en attente |
|
| 339 | + if (is_array($force_jobs) and count($force_jobs)) { |
|
| 340 | + $cond = 'status=' . intval(_JQ_SCHEDULED) . ' AND ' . sql_in('id_job', $force_jobs); |
|
| 341 | + } else { |
|
| 342 | + $now = date('Y-m-d H:i:s', $time); |
|
| 343 | + $cond = 'status=' . intval(_JQ_SCHEDULED) . ' AND date<=' . sql_quote($now); |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + register_shutdown_function('queue_error_handler'); // recuperer les erreurs auant que possible |
|
| 347 | + $res = sql_allfetsel('*', 'spip_jobs', $cond, '', 'priorite DESC,date', '0,' . (_JQ_MAX_JOBS_EXECUTE + 1)); |
|
| 348 | + do { |
|
| 349 | + if ($row = array_shift($res)) { |
|
| 350 | + $nbj++; |
|
| 351 | + // il faut un verrou, a base de sql_delete |
|
| 352 | + if (sql_delete('spip_jobs', 'id_job=' . intval($row['id_job']) . ' AND status=' . intval(_JQ_SCHEDULED))) { |
|
| 353 | + #spip_log("JQ schedule job ".$nbj." OK",'jq'); |
|
| 354 | + // on reinsert dans la base aussitot avec un status=_JQ_PENDING |
|
| 355 | + $row['status'] = _JQ_PENDING; |
|
| 356 | + $row['date'] = date('Y-m-d H:i:s', $time); |
|
| 357 | + sql_insertq('spip_jobs', $row); |
|
| 358 | + |
|
| 359 | + // on a la main sur le job : |
|
| 360 | + // l'executer |
|
| 361 | + $result = queue_start_job($row); |
|
| 362 | + |
|
| 363 | + $time = time(); |
|
| 364 | + queue_close_job($row, $time, $result); |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + spip_log('JQ schedule job end time ' . $time, 'jq' . _LOG_DEBUG); |
|
| 368 | + } while ($nbj < _JQ_MAX_JOBS_EXECUTE and $row and $time < $end_time); |
|
| 369 | + spip_log('JQ schedule end time ' . time(), 'jq' . _LOG_DEBUG); |
|
| 370 | + |
|
| 371 | + if ($row = array_shift($res)) { |
|
| 372 | + queue_update_next_job_time(0); // on sait qu'il y a encore des jobs a lancer ASAP |
|
| 373 | + spip_log('JQ encore !', 'jq' . _LOG_DEBUG); |
|
| 374 | + } else { |
|
| 375 | + queue_update_next_job_time(); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + return true; |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -393,21 +393,21 @@ discard block |
||
| 393 | 393 | * @param int $result |
| 394 | 394 | */ |
| 395 | 395 | function queue_close_job(&$row, $time, $result = 0) { |
| 396 | - // est-ce une tache cron qu'il faut relancer ? |
|
| 397 | - if ($periode = queue_is_cron_job($row['fonction'], $row['inclure'])) { |
|
| 398 | - // relancer avec les nouveaux arguments de temps |
|
| 399 | - include_spip('inc/genie'); |
|
| 400 | - if ($result < 0) { // relancer tout de suite, mais en baissant la priorite |
|
| 401 | - queue_genie_replan_job($row['fonction'], $periode, 0 - $result, null, $row['priorite'] - 1); |
|
| 402 | - } else // relancer avec la periode prevue |
|
| 403 | - { |
|
| 404 | - queue_genie_replan_job($row['fonction'], $periode, $time); |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - // purger ses liens eventuels avec des objets |
|
| 408 | - sql_delete('spip_jobs_liens', 'id_job=' . intval($row['id_job'])); |
|
| 409 | - // supprimer le job fini |
|
| 410 | - sql_delete('spip_jobs', 'id_job=' . intval($row['id_job'])); |
|
| 396 | + // est-ce une tache cron qu'il faut relancer ? |
|
| 397 | + if ($periode = queue_is_cron_job($row['fonction'], $row['inclure'])) { |
|
| 398 | + // relancer avec les nouveaux arguments de temps |
|
| 399 | + include_spip('inc/genie'); |
|
| 400 | + if ($result < 0) { // relancer tout de suite, mais en baissant la priorite |
|
| 401 | + queue_genie_replan_job($row['fonction'], $periode, 0 - $result, null, $row['priorite'] - 1); |
|
| 402 | + } else // relancer avec la periode prevue |
|
| 403 | + { |
|
| 404 | + queue_genie_replan_job($row['fonction'], $periode, $time); |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + // purger ses liens eventuels avec des objets |
|
| 408 | + sql_delete('spip_jobs_liens', 'id_job=' . intval($row['id_job'])); |
|
| 409 | + // supprimer le job fini |
|
| 410 | + sql_delete('spip_jobs', 'id_job=' . intval($row['id_job'])); |
|
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -417,10 +417,10 @@ discard block |
||
| 417 | 417 | * @uses queue_update_next_job_time() |
| 418 | 418 | */ |
| 419 | 419 | function queue_error_handler() { |
| 420 | - // se remettre dans le bon dossier, car Apache le change parfois (toujours?) |
|
| 421 | - chdir(_ROOT_CWD); |
|
| 420 | + // se remettre dans le bon dossier, car Apache le change parfois (toujours?) |
|
| 421 | + chdir(_ROOT_CWD); |
|
| 422 | 422 | |
| 423 | - queue_update_next_job_time(); |
|
| 423 | + queue_update_next_job_time(); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | |
@@ -437,18 +437,18 @@ discard block |
||
| 437 | 437 | * Périodicité de la tâche en secondes, si tâche périodique, sinon false. |
| 438 | 438 | */ |
| 439 | 439 | function queue_is_cron_job($function, $inclure) { |
| 440 | - static $taches = null; |
|
| 441 | - if (strncmp($inclure, 'genie/', 6) == 0) { |
|
| 442 | - if (is_null($taches)) { |
|
| 443 | - include_spip('inc/genie'); |
|
| 444 | - $taches = taches_generales(); |
|
| 445 | - } |
|
| 446 | - if (isset($taches[$function])) { |
|
| 447 | - return $taches[$function]; |
|
| 448 | - } |
|
| 449 | - } |
|
| 450 | - |
|
| 451 | - return false; |
|
| 440 | + static $taches = null; |
|
| 441 | + if (strncmp($inclure, 'genie/', 6) == 0) { |
|
| 442 | + if (is_null($taches)) { |
|
| 443 | + include_spip('inc/genie'); |
|
| 444 | + $taches = taches_generales(); |
|
| 445 | + } |
|
| 446 | + if (isset($taches[$function])) { |
|
| 447 | + return $taches[$function]; |
|
| 448 | + } |
|
| 449 | + } |
|
| 450 | + |
|
| 451 | + return false; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -462,62 +462,62 @@ discard block |
||
| 462 | 462 | * temps de la tache ajoutee ou 0 pour ASAP |
| 463 | 463 | */ |
| 464 | 464 | function queue_update_next_job_time($next_time = null) { |
| 465 | - static $nb_jobs_scheduled = null; |
|
| 466 | - static $deja_la = false; |
|
| 467 | - // prendre le min des $next_time que l'on voit passer ici, en cas de reentrance |
|
| 468 | - static $next = null; |
|
| 469 | - // queue_close_job peut etre reentrant ici |
|
| 470 | - if ($deja_la) { |
|
| 471 | - return; |
|
| 472 | - } |
|
| 473 | - $deja_la = true; |
|
| 474 | - |
|
| 475 | - include_spip('base/abstract_sql'); |
|
| 476 | - $time = time(); |
|
| 477 | - |
|
| 478 | - // traiter les jobs morts au combat (_JQ_PENDING depuis plus de 180s) |
|
| 479 | - // pour cause de timeout ou autre erreur fatale |
|
| 480 | - $res = sql_allfetsel( |
|
| 481 | - '*', |
|
| 482 | - 'spip_jobs', |
|
| 483 | - 'status=' . intval(_JQ_PENDING) . ' AND date<' . sql_quote(date('Y-m-d H:i:s', $time - 180)) |
|
| 484 | - ); |
|
| 485 | - if (is_array($res)) { |
|
| 486 | - foreach ($res as $row) { |
|
| 487 | - queue_close_job($row, $time); |
|
| 488 | - spip_log('queue_close_job car _JQ_PENDING depuis +180s : ' . print_r($row, 1), 'job_mort' . _LOG_ERREUR); |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - // chercher la date du prochain job si pas connu |
|
| 493 | - if (is_null($next) or is_null(queue_sleep_time_to_next_job())) { |
|
| 494 | - $date = sql_getfetsel('date', 'spip_jobs', 'status=' . intval(_JQ_SCHEDULED), '', 'date', '0,1'); |
|
| 495 | - $next = strtotime($date); |
|
| 496 | - } |
|
| 497 | - if (!is_null($next_time)) { |
|
| 498 | - if (is_null($next) or $next > $next_time) { |
|
| 499 | - $next = $next_time; |
|
| 500 | - } |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - if ($next) { |
|
| 504 | - if (is_null($nb_jobs_scheduled)) { |
|
| 505 | - $nb_jobs_scheduled = sql_countsel( |
|
| 506 | - 'spip_jobs', |
|
| 507 | - 'status=' . intval(_JQ_SCHEDULED) . ' AND date<' . sql_quote(date('Y-m-d H:i:s', $time)) |
|
| 508 | - ); |
|
| 509 | - } elseif ($next <= $time) { |
|
| 510 | - $nb_jobs_scheduled++; |
|
| 511 | - } |
|
| 512 | - // si trop de jobs en attente, on force la purge en fin de hit |
|
| 513 | - // pour assurer le coup |
|
| 514 | - if ($nb_jobs_scheduled > (defined('_JQ_NB_JOBS_OVERFLOW') ? _JQ_NB_JOBS_OVERFLOW : 10000)) { |
|
| 515 | - define('_DIRECT_CRON_FORCE', true); |
|
| 516 | - } |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - queue_set_next_job_time($next); |
|
| 520 | - $deja_la = false; |
|
| 465 | + static $nb_jobs_scheduled = null; |
|
| 466 | + static $deja_la = false; |
|
| 467 | + // prendre le min des $next_time que l'on voit passer ici, en cas de reentrance |
|
| 468 | + static $next = null; |
|
| 469 | + // queue_close_job peut etre reentrant ici |
|
| 470 | + if ($deja_la) { |
|
| 471 | + return; |
|
| 472 | + } |
|
| 473 | + $deja_la = true; |
|
| 474 | + |
|
| 475 | + include_spip('base/abstract_sql'); |
|
| 476 | + $time = time(); |
|
| 477 | + |
|
| 478 | + // traiter les jobs morts au combat (_JQ_PENDING depuis plus de 180s) |
|
| 479 | + // pour cause de timeout ou autre erreur fatale |
|
| 480 | + $res = sql_allfetsel( |
|
| 481 | + '*', |
|
| 482 | + 'spip_jobs', |
|
| 483 | + 'status=' . intval(_JQ_PENDING) . ' AND date<' . sql_quote(date('Y-m-d H:i:s', $time - 180)) |
|
| 484 | + ); |
|
| 485 | + if (is_array($res)) { |
|
| 486 | + foreach ($res as $row) { |
|
| 487 | + queue_close_job($row, $time); |
|
| 488 | + spip_log('queue_close_job car _JQ_PENDING depuis +180s : ' . print_r($row, 1), 'job_mort' . _LOG_ERREUR); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + // chercher la date du prochain job si pas connu |
|
| 493 | + if (is_null($next) or is_null(queue_sleep_time_to_next_job())) { |
|
| 494 | + $date = sql_getfetsel('date', 'spip_jobs', 'status=' . intval(_JQ_SCHEDULED), '', 'date', '0,1'); |
|
| 495 | + $next = strtotime($date); |
|
| 496 | + } |
|
| 497 | + if (!is_null($next_time)) { |
|
| 498 | + if (is_null($next) or $next > $next_time) { |
|
| 499 | + $next = $next_time; |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + if ($next) { |
|
| 504 | + if (is_null($nb_jobs_scheduled)) { |
|
| 505 | + $nb_jobs_scheduled = sql_countsel( |
|
| 506 | + 'spip_jobs', |
|
| 507 | + 'status=' . intval(_JQ_SCHEDULED) . ' AND date<' . sql_quote(date('Y-m-d H:i:s', $time)) |
|
| 508 | + ); |
|
| 509 | + } elseif ($next <= $time) { |
|
| 510 | + $nb_jobs_scheduled++; |
|
| 511 | + } |
|
| 512 | + // si trop de jobs en attente, on force la purge en fin de hit |
|
| 513 | + // pour assurer le coup |
|
| 514 | + if ($nb_jobs_scheduled > (defined('_JQ_NB_JOBS_OVERFLOW') ? _JQ_NB_JOBS_OVERFLOW : 10000)) { |
|
| 515 | + define('_DIRECT_CRON_FORCE', true); |
|
| 516 | + } |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + queue_set_next_job_time($next); |
|
| 520 | + $deja_la = false; |
|
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | |
@@ -528,26 +528,26 @@ discard block |
||
| 528 | 528 | */ |
| 529 | 529 | function queue_set_next_job_time($next) { |
| 530 | 530 | |
| 531 | - // utiliser le temps courant reel plutot que temps de la requete ici |
|
| 532 | - $time = time(); |
|
| 533 | - |
|
| 534 | - // toujours relire la valeur pour comparer, pour tenir compte des maj concourrantes |
|
| 535 | - // et ne mettre a jour que si il y a un interet a le faire |
|
| 536 | - // permet ausis d'initialiser le nom de fichier a coup sur |
|
| 537 | - $curr_next = $_SERVER['REQUEST_TIME'] + max(0, queue_sleep_time_to_next_job(true)); |
|
| 538 | - if ( |
|
| 539 | - ($curr_next <= $time and $next > $time) // le prochain job est dans le futur mais pas la date planifiee actuelle |
|
| 540 | - or $curr_next > $next // le prochain job est plus tot que la date planifiee actuelle |
|
| 541 | - ) { |
|
| 542 | - if (function_exists('cache_set') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 543 | - cache_set(_JQ_NEXT_JOB_TIME_FILENAME, intval($next)); |
|
| 544 | - } else { |
|
| 545 | - ecrire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, intval($next)); |
|
| 546 | - } |
|
| 547 | - queue_sleep_time_to_next_job($next); |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - return queue_sleep_time_to_next_job(); |
|
| 531 | + // utiliser le temps courant reel plutot que temps de la requete ici |
|
| 532 | + $time = time(); |
|
| 533 | + |
|
| 534 | + // toujours relire la valeur pour comparer, pour tenir compte des maj concourrantes |
|
| 535 | + // et ne mettre a jour que si il y a un interet a le faire |
|
| 536 | + // permet ausis d'initialiser le nom de fichier a coup sur |
|
| 537 | + $curr_next = $_SERVER['REQUEST_TIME'] + max(0, queue_sleep_time_to_next_job(true)); |
|
| 538 | + if ( |
|
| 539 | + ($curr_next <= $time and $next > $time) // le prochain job est dans le futur mais pas la date planifiee actuelle |
|
| 540 | + or $curr_next > $next // le prochain job est plus tot que la date planifiee actuelle |
|
| 541 | + ) { |
|
| 542 | + if (function_exists('cache_set') and defined('_MEMOIZE_MEMORY') and _MEMOIZE_MEMORY) { |
|
| 543 | + cache_set(_JQ_NEXT_JOB_TIME_FILENAME, intval($next)); |
|
| 544 | + } else { |
|
| 545 | + ecrire_fichier(_JQ_NEXT_JOB_TIME_FILENAME, intval($next)); |
|
| 546 | + } |
|
| 547 | + queue_sleep_time_to_next_job($next); |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + return queue_sleep_time_to_next_job(); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -564,60 +564,60 @@ discard block |
||
| 564 | 564 | * @return string |
| 565 | 565 | */ |
| 566 | 566 | function queue_affichage_cron() { |
| 567 | - $texte = ''; |
|
| 568 | - |
|
| 569 | - $time_to_next = queue_sleep_time_to_next_job(); |
|
| 570 | - // rien a faire si le prochain job est encore dans le futur |
|
| 571 | - if ($time_to_next > 0 or defined('_DEBUG_BLOCK_QUEUE')) { |
|
| 572 | - return $texte; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - // ne pas relancer si on vient de lancer dans la meme seconde par un hit concurent |
|
| 576 | - if (file_exists($lock = _DIR_TMP . 'cron.lock') and !(@filemtime($lock) < $_SERVER['REQUEST_TIME'])) { |
|
| 577 | - return $texte; |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - @touch($lock); |
|
| 581 | - |
|
| 582 | - // il y a des taches en attentes |
|
| 583 | - // si depuis plus de 5min, on essaye de lancer le cron par tous les moyens pour rattraper le coup |
|
| 584 | - // on est sans doute sur un site qui n'autorise pas http sortant ou avec peu de trafic |
|
| 585 | - $urgent = false; |
|
| 586 | - if ($time_to_next < -300) { |
|
| 587 | - $urgent = true; |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - $url_cron = generer_url_action('cron', '', false, true); |
|
| 591 | - |
|
| 592 | - if (!defined('_HTML_BG_CRON_FORCE') or !_HTML_BG_CRON_FORCE) { |
|
| 593 | - if (queue_lancer_url_http_async($url_cron) and !$urgent) { |
|
| 594 | - return $texte; |
|
| 595 | - } |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - // si deja force, on retourne sans rien |
|
| 599 | - if (defined('_DIRECT_CRON_FORCE')) { |
|
| 600 | - return $texte; |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - // si c'est un bot |
|
| 604 | - // inutile de faire un appel par image background, |
|
| 605 | - // on force un appel direct en fin de hit |
|
| 606 | - if ((defined('_IS_BOT') and _IS_BOT)) { |
|
| 607 | - define('_DIRECT_CRON_FORCE', true); |
|
| 608 | - |
|
| 609 | - return $texte; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - if (!defined('_HTML_BG_CRON_INHIB') or !_HTML_BG_CRON_INHIB) { |
|
| 613 | - // en derniere solution, on insere un appel xhr non bloquant ou une image background dans la page si pas de JS |
|
| 614 | - $url_cron = generer_url_action('cron'); |
|
| 615 | - $texte = '<!-- SPIP-CRON -->' |
|
| 616 | - . "<script>setTimeout(function(){var xo = new XMLHttpRequest();xo.open('GET', '$url_cron', true);xo.send('');},100);</script>" |
|
| 617 | - . "<noscript><div style=\"background-image: url('$url_cron');\"></div></noscript>"; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - return $texte; |
|
| 567 | + $texte = ''; |
|
| 568 | + |
|
| 569 | + $time_to_next = queue_sleep_time_to_next_job(); |
|
| 570 | + // rien a faire si le prochain job est encore dans le futur |
|
| 571 | + if ($time_to_next > 0 or defined('_DEBUG_BLOCK_QUEUE')) { |
|
| 572 | + return $texte; |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + // ne pas relancer si on vient de lancer dans la meme seconde par un hit concurent |
|
| 576 | + if (file_exists($lock = _DIR_TMP . 'cron.lock') and !(@filemtime($lock) < $_SERVER['REQUEST_TIME'])) { |
|
| 577 | + return $texte; |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + @touch($lock); |
|
| 581 | + |
|
| 582 | + // il y a des taches en attentes |
|
| 583 | + // si depuis plus de 5min, on essaye de lancer le cron par tous les moyens pour rattraper le coup |
|
| 584 | + // on est sans doute sur un site qui n'autorise pas http sortant ou avec peu de trafic |
|
| 585 | + $urgent = false; |
|
| 586 | + if ($time_to_next < -300) { |
|
| 587 | + $urgent = true; |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + $url_cron = generer_url_action('cron', '', false, true); |
|
| 591 | + |
|
| 592 | + if (!defined('_HTML_BG_CRON_FORCE') or !_HTML_BG_CRON_FORCE) { |
|
| 593 | + if (queue_lancer_url_http_async($url_cron) and !$urgent) { |
|
| 594 | + return $texte; |
|
| 595 | + } |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + // si deja force, on retourne sans rien |
|
| 599 | + if (defined('_DIRECT_CRON_FORCE')) { |
|
| 600 | + return $texte; |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + // si c'est un bot |
|
| 604 | + // inutile de faire un appel par image background, |
|
| 605 | + // on force un appel direct en fin de hit |
|
| 606 | + if ((defined('_IS_BOT') and _IS_BOT)) { |
|
| 607 | + define('_DIRECT_CRON_FORCE', true); |
|
| 608 | + |
|
| 609 | + return $texte; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + if (!defined('_HTML_BG_CRON_INHIB') or !_HTML_BG_CRON_INHIB) { |
|
| 613 | + // en derniere solution, on insere un appel xhr non bloquant ou une image background dans la page si pas de JS |
|
| 614 | + $url_cron = generer_url_action('cron'); |
|
| 615 | + $texte = '<!-- SPIP-CRON -->' |
|
| 616 | + . "<script>setTimeout(function(){var xo = new XMLHttpRequest();xo.open('GET', '$url_cron', true);xo.send('');},100);</script>" |
|
| 617 | + . "<noscript><div style=\"background-image: url('$url_cron');\"></div></noscript>"; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + return $texte; |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -626,73 +626,73 @@ discard block |
||
| 626 | 626 | * @return bool : true si l'url a pu être appelée en asynchrone, false sinon |
| 627 | 627 | */ |
| 628 | 628 | function queue_lancer_url_http_async($url_cron) { |
| 629 | - // methode la plus rapide : |
|
| 630 | - // Si fsockopen est possible, on lance le cron via un socket en asynchrone |
|
| 631 | - // si fsockopen echoue (disponibilite serveur, firewall) on essaye pas cURL |
|
| 632 | - // car on a toutes les chances d'echouer pareil mais sans moyen de le savoir |
|
| 633 | - // mais on renvoie false direct |
|
| 634 | - if (function_exists('fsockopen')) { |
|
| 635 | - $parts = parse_url($url_cron); |
|
| 636 | - |
|
| 637 | - switch ($parts['scheme']) { |
|
| 638 | - case 'https': |
|
| 639 | - $scheme = 'ssl://'; |
|
| 640 | - $port = 443; |
|
| 641 | - break; |
|
| 642 | - case 'http': |
|
| 643 | - default: |
|
| 644 | - $scheme = ''; |
|
| 645 | - $port = 80; |
|
| 646 | - } |
|
| 647 | - $fp = @fsockopen( |
|
| 648 | - $scheme . $parts['host'], |
|
| 649 | - $parts['port'] ?? $port, |
|
| 650 | - $errno, |
|
| 651 | - $errstr, |
|
| 652 | - 1 |
|
| 653 | - ); |
|
| 654 | - |
|
| 655 | - if ($fp) { |
|
| 656 | - $host_sent = $parts['host']; |
|
| 657 | - if (isset($parts['port']) and $parts['port'] !== $port) { |
|
| 658 | - $host_sent .= ':' . $parts['port']; |
|
| 659 | - } |
|
| 660 | - $timeout = 200; // ms |
|
| 661 | - stream_set_timeout($fp, 0, $timeout * 1000); |
|
| 662 | - $query = $parts['path'] . ($parts['query'] ? '?' . $parts['query'] : ''); |
|
| 663 | - $out = 'GET ' . $query . " HTTP/1.1\r\n"; |
|
| 664 | - $out .= 'Host: ' . $host_sent . "\r\n"; |
|
| 665 | - $out .= "Connection: Close\r\n\r\n"; |
|
| 666 | - fwrite($fp, $out); |
|
| 667 | - spip_timer('read'); |
|
| 668 | - $t = 0; |
|
| 669 | - // on lit la reponse si possible pour fermer proprement la connexion |
|
| 670 | - // avec un timeout total de 200ms pour ne pas se bloquer |
|
| 671 | - while (!feof($fp) and $t < $timeout) { |
|
| 672 | - @fgets($fp, 1024); |
|
| 673 | - $t += spip_timer('read', true); |
|
| 674 | - spip_timer('read'); |
|
| 675 | - } |
|
| 676 | - fclose($fp); |
|
| 677 | - return true; |
|
| 678 | - } |
|
| 679 | - } |
|
| 680 | - // si fsockopen n'est pas dispo on essaye cURL : |
|
| 681 | - // lancer le cron par un cURL asynchrone si cURL est present |
|
| 682 | - elseif (function_exists('curl_init')) { |
|
| 683 | - //setting the curl parameters. |
|
| 684 | - $ch = curl_init($url_cron); |
|
| 685 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 686 | - // cf bug : http://www.php.net/manual/en/function.curl-setopt.php#104597 |
|
| 687 | - curl_setopt($ch, CURLOPT_NOSIGNAL, 1); |
|
| 688 | - // valeur mini pour que la requete soit lancee |
|
| 689 | - curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200); |
|
| 690 | - // lancer |
|
| 691 | - curl_exec($ch); |
|
| 692 | - // fermer |
|
| 693 | - curl_close($ch); |
|
| 694 | - return true; |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - return false; |
|
| 629 | + // methode la plus rapide : |
|
| 630 | + // Si fsockopen est possible, on lance le cron via un socket en asynchrone |
|
| 631 | + // si fsockopen echoue (disponibilite serveur, firewall) on essaye pas cURL |
|
| 632 | + // car on a toutes les chances d'echouer pareil mais sans moyen de le savoir |
|
| 633 | + // mais on renvoie false direct |
|
| 634 | + if (function_exists('fsockopen')) { |
|
| 635 | + $parts = parse_url($url_cron); |
|
| 636 | + |
|
| 637 | + switch ($parts['scheme']) { |
|
| 638 | + case 'https': |
|
| 639 | + $scheme = 'ssl://'; |
|
| 640 | + $port = 443; |
|
| 641 | + break; |
|
| 642 | + case 'http': |
|
| 643 | + default: |
|
| 644 | + $scheme = ''; |
|
| 645 | + $port = 80; |
|
| 646 | + } |
|
| 647 | + $fp = @fsockopen( |
|
| 648 | + $scheme . $parts['host'], |
|
| 649 | + $parts['port'] ?? $port, |
|
| 650 | + $errno, |
|
| 651 | + $errstr, |
|
| 652 | + 1 |
|
| 653 | + ); |
|
| 654 | + |
|
| 655 | + if ($fp) { |
|
| 656 | + $host_sent = $parts['host']; |
|
| 657 | + if (isset($parts['port']) and $parts['port'] !== $port) { |
|
| 658 | + $host_sent .= ':' . $parts['port']; |
|
| 659 | + } |
|
| 660 | + $timeout = 200; // ms |
|
| 661 | + stream_set_timeout($fp, 0, $timeout * 1000); |
|
| 662 | + $query = $parts['path'] . ($parts['query'] ? '?' . $parts['query'] : ''); |
|
| 663 | + $out = 'GET ' . $query . " HTTP/1.1\r\n"; |
|
| 664 | + $out .= 'Host: ' . $host_sent . "\r\n"; |
|
| 665 | + $out .= "Connection: Close\r\n\r\n"; |
|
| 666 | + fwrite($fp, $out); |
|
| 667 | + spip_timer('read'); |
|
| 668 | + $t = 0; |
|
| 669 | + // on lit la reponse si possible pour fermer proprement la connexion |
|
| 670 | + // avec un timeout total de 200ms pour ne pas se bloquer |
|
| 671 | + while (!feof($fp) and $t < $timeout) { |
|
| 672 | + @fgets($fp, 1024); |
|
| 673 | + $t += spip_timer('read', true); |
|
| 674 | + spip_timer('read'); |
|
| 675 | + } |
|
| 676 | + fclose($fp); |
|
| 677 | + return true; |
|
| 678 | + } |
|
| 679 | + } |
|
| 680 | + // si fsockopen n'est pas dispo on essaye cURL : |
|
| 681 | + // lancer le cron par un cURL asynchrone si cURL est present |
|
| 682 | + elseif (function_exists('curl_init')) { |
|
| 683 | + //setting the curl parameters. |
|
| 684 | + $ch = curl_init($url_cron); |
|
| 685 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 686 | + // cf bug : http://www.php.net/manual/en/function.curl-setopt.php#104597 |
|
| 687 | + curl_setopt($ch, CURLOPT_NOSIGNAL, 1); |
|
| 688 | + // valeur mini pour que la requete soit lancee |
|
| 689 | + curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200); |
|
| 690 | + // lancer |
|
| 691 | + curl_exec($ch); |
|
| 692 | + // fermer |
|
| 693 | + curl_close($ch); |
|
| 694 | + return true; |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + return false; |
|
| 698 | 698 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $md5args = md5($arguments); |
| 71 | 71 | |
| 72 | 72 | // si pas de date programee, des que possible |
| 73 | - $duplicate_where = 'status=' . intval(_JQ_SCHEDULED) . ' AND '; |
|
| 73 | + $duplicate_where = 'status='.intval(_JQ_SCHEDULED).' AND '; |
|
| 74 | 74 | if (!$time) { |
| 75 | 75 | $time = time(); |
| 76 | 76 | $duplicate_where = ''; // ne pas dupliquer si deja le meme job en cours d'execution |
@@ -96,9 +96,8 @@ discard block |
||
| 96 | 96 | 'id_job', |
| 97 | 97 | 'spip_jobs', |
| 98 | 98 | $duplicate_where = |
| 99 | - $duplicate_where . 'fonction=' . sql_quote($function) |
|
| 100 | - . (($no_duplicate === 'function_only') ? '' : |
|
| 101 | - ' AND md5args=' . sql_quote($md5args) . ' AND inclure=' . sql_quote($file)) |
|
| 99 | + $duplicate_where.'fonction='.sql_quote($function) |
|
| 100 | + . (($no_duplicate === 'function_only') ? '' : ' AND md5args='.sql_quote($md5args).' AND inclure='.sql_quote($file)) |
|
| 102 | 101 | ) |
| 103 | 102 | ) { |
| 104 | 103 | return $id_job; |
@@ -111,9 +110,9 @@ discard block |
||
| 111 | 110 | if ( |
| 112 | 111 | $no_duplicate |
| 113 | 112 | and |
| 114 | - $id_prev = sql_getfetsel('id_job', 'spip_jobs', 'id_job<' . intval($id_job) . " AND $duplicate_where") |
|
| 113 | + $id_prev = sql_getfetsel('id_job', 'spip_jobs', 'id_job<'.intval($id_job)." AND $duplicate_where") |
|
| 115 | 114 | ) { |
| 116 | - sql_delete('spip_jobs', 'id_job=' . intval($id_job)); |
|
| 115 | + sql_delete('spip_jobs', 'id_job='.intval($id_job)); |
|
| 117 | 116 | |
| 118 | 117 | return $id_prev; |
| 119 | 118 | } |
@@ -125,9 +124,9 @@ discard block |
||
| 125 | 124 | // ie cas d'un char non acceptables sur certains type de champs |
| 126 | 125 | // qui coupe la valeur |
| 127 | 126 | if (defined('_JQ_INSERT_CHECK_ARGS') and $id_job) { |
| 128 | - $args = sql_getfetsel('args', 'spip_jobs', 'id_job=' . intval($id_job)); |
|
| 127 | + $args = sql_getfetsel('args', 'spip_jobs', 'id_job='.intval($id_job)); |
|
| 129 | 128 | if ($args !== $arguments) { |
| 130 | - spip_log('arguments job errones / longueur ' . strlen($args) . ' vs ' . strlen($arguments) . ' / valeur : ' . var_export( |
|
| 129 | + spip_log('arguments job errones / longueur '.strlen($args).' vs '.strlen($arguments).' / valeur : '.var_export( |
|
| 131 | 130 | $arguments, |
| 132 | 131 | true |
| 133 | 132 | ), 'queue'); |
@@ -157,7 +156,7 @@ discard block |
||
| 157 | 156 | function queue_purger() { |
| 158 | 157 | include_spip('base/abstract_sql'); |
| 159 | 158 | sql_delete('spip_jobs'); |
| 160 | - sql_delete('spip_jobs_liens', 'id_job NOT IN (' . sql_get_select('id_job', 'spip_jobs') . ')'); |
|
| 159 | + sql_delete('spip_jobs_liens', 'id_job NOT IN ('.sql_get_select('id_job', 'spip_jobs').')'); |
|
| 161 | 160 | include_spip('inc/genie'); |
| 162 | 161 | genie_queue_watch_dist(); |
| 163 | 162 | } |
@@ -173,8 +172,8 @@ discard block |
||
| 173 | 172 | include_spip('base/abstract_sql'); |
| 174 | 173 | |
| 175 | 174 | if ( |
| 176 | - $row = sql_fetsel('fonction,inclure,date', 'spip_jobs', 'id_job=' . intval($id_job)) |
|
| 177 | - and $res = sql_delete('spip_jobs', 'id_job=' . intval($id_job)) |
|
| 175 | + $row = sql_fetsel('fonction,inclure,date', 'spip_jobs', 'id_job='.intval($id_job)) |
|
| 176 | + and $res = sql_delete('spip_jobs', 'id_job='.intval($id_job)) |
|
| 178 | 177 | ) { |
| 179 | 178 | queue_unlink_job($id_job); |
| 180 | 179 | // est-ce une tache cron qu'il faut relancer ? |
@@ -224,7 +223,7 @@ discard block |
||
| 224 | 223 | * resultat du sql_delete |
| 225 | 224 | */ |
| 226 | 225 | function queue_unlink_job($id_job) { |
| 227 | - return sql_delete('spip_jobs_liens', 'id_job=' . intval($id_job)); |
|
| 226 | + return sql_delete('spip_jobs_liens', 'id_job='.intval($id_job)); |
|
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | /** |
@@ -240,7 +239,7 @@ discard block |
||
| 240 | 239 | // deserialiser les arguments |
| 241 | 240 | $args = unserialize($row['args']); |
| 242 | 241 | if (!is_array($args)) { |
| 243 | - spip_log('arguments job errones ' . var_export($row, true), 'queue'); |
|
| 242 | + spip_log('arguments job errones '.var_export($row, true), 'queue'); |
|
| 244 | 243 | $args = []; |
| 245 | 244 | } |
| 246 | 245 | |
@@ -257,14 +256,14 @@ discard block |
||
| 257 | 256 | } |
| 258 | 257 | |
| 259 | 258 | if (!function_exists($fonction)) { |
| 260 | - spip_log("fonction $fonction ($inclure) inexistante " . var_export($row, true), 'queue'); |
|
| 259 | + spip_log("fonction $fonction ($inclure) inexistante ".var_export($row, true), 'queue'); |
|
| 261 | 260 | |
| 262 | 261 | return false; |
| 263 | 262 | } |
| 264 | 263 | |
| 265 | - spip_log('queue [' . $row['id_job'] . "]: $fonction() start", 'queue'); |
|
| 264 | + spip_log('queue ['.$row['id_job']."]: $fonction() start", 'queue'); |
|
| 266 | 265 | $res = $fonction(...$args); |
| 267 | - spip_log('queue [' . $row['id_job'] . "]: $fonction() end", 'queue'); |
|
| 266 | + spip_log('queue ['.$row['id_job']."]: $fonction() end", 'queue'); |
|
| 268 | 267 | |
| 269 | 268 | return $res; |
| 270 | 269 | } |
@@ -295,14 +294,14 @@ discard block |
||
| 295 | 294 | function queue_schedule($force_jobs = null) { |
| 296 | 295 | $time = time(); |
| 297 | 296 | if (defined('_DEBUG_BLOCK_QUEUE')) { |
| 298 | - spip_log('_DEBUG_BLOCK_QUEUE : schedule stop', 'jq' . _LOG_DEBUG); |
|
| 297 | + spip_log('_DEBUG_BLOCK_QUEUE : schedule stop', 'jq'._LOG_DEBUG); |
|
| 299 | 298 | |
| 300 | 299 | return; |
| 301 | 300 | } |
| 302 | 301 | |
| 303 | 302 | // rien a faire si le prochain job est encore dans le futur |
| 304 | 303 | if (queue_sleep_time_to_next_job() > 0 and (!$force_jobs or !count($force_jobs))) { |
| 305 | - spip_log('queue_sleep_time_to_next_job', 'jq' . _LOG_DEBUG); |
|
| 304 | + spip_log('queue_sleep_time_to_next_job', 'jq'._LOG_DEBUG); |
|
| 306 | 305 | |
| 307 | 306 | return; |
| 308 | 307 | } |
@@ -323,7 +322,7 @@ discard block |
||
| 323 | 322 | } |
| 324 | 323 | $end_time = $time + _JQ_MAX_JOBS_TIME_TO_EXECUTE; |
| 325 | 324 | |
| 326 | - spip_log("JQ schedule $time / $end_time", 'jq' . _LOG_DEBUG); |
|
| 325 | + spip_log("JQ schedule $time / $end_time", 'jq'._LOG_DEBUG); |
|
| 327 | 326 | |
| 328 | 327 | if (!defined('_JQ_MAX_JOBS_EXECUTE')) { |
| 329 | 328 | define('_JQ_MAX_JOBS_EXECUTE', 200); |
@@ -337,19 +336,19 @@ discard block |
||
| 337 | 336 | // lorsqu'un job cron n'a pas fini, sa priorite est descendue |
| 338 | 337 | // pour qu'il ne bloque pas les autres jobs en attente |
| 339 | 338 | if (is_array($force_jobs) and count($force_jobs)) { |
| 340 | - $cond = 'status=' . intval(_JQ_SCHEDULED) . ' AND ' . sql_in('id_job', $force_jobs); |
|
| 339 | + $cond = 'status='.intval(_JQ_SCHEDULED).' AND '.sql_in('id_job', $force_jobs); |
|
| 341 | 340 | } else { |
| 342 | 341 | $now = date('Y-m-d H:i:s', $time); |
| 343 | - $cond = 'status=' . intval(_JQ_SCHEDULED) . ' AND date<=' . sql_quote($now); |
|
| 342 | + $cond = 'status='.intval(_JQ_SCHEDULED).' AND date<='.sql_quote($now); |
|
| 344 | 343 | } |
| 345 | 344 | |
| 346 | 345 | register_shutdown_function('queue_error_handler'); // recuperer les erreurs auant que possible |
| 347 | - $res = sql_allfetsel('*', 'spip_jobs', $cond, '', 'priorite DESC,date', '0,' . (_JQ_MAX_JOBS_EXECUTE + 1)); |
|
| 346 | + $res = sql_allfetsel('*', 'spip_jobs', $cond, '', 'priorite DESC,date', '0,'.(_JQ_MAX_JOBS_EXECUTE + 1)); |
|
| 348 | 347 | do { |
| 349 | 348 | if ($row = array_shift($res)) { |
| 350 | 349 | $nbj++; |
| 351 | 350 | // il faut un verrou, a base de sql_delete |
| 352 | - if (sql_delete('spip_jobs', 'id_job=' . intval($row['id_job']) . ' AND status=' . intval(_JQ_SCHEDULED))) { |
|
| 351 | + if (sql_delete('spip_jobs', 'id_job='.intval($row['id_job']).' AND status='.intval(_JQ_SCHEDULED))) { |
|
| 353 | 352 | #spip_log("JQ schedule job ".$nbj." OK",'jq'); |
| 354 | 353 | // on reinsert dans la base aussitot avec un status=_JQ_PENDING |
| 355 | 354 | $row['status'] = _JQ_PENDING; |
@@ -364,13 +363,13 @@ discard block |
||
| 364 | 363 | queue_close_job($row, $time, $result); |
| 365 | 364 | } |
| 366 | 365 | } |
| 367 | - spip_log('JQ schedule job end time ' . $time, 'jq' . _LOG_DEBUG); |
|
| 366 | + spip_log('JQ schedule job end time '.$time, 'jq'._LOG_DEBUG); |
|
| 368 | 367 | } while ($nbj < _JQ_MAX_JOBS_EXECUTE and $row and $time < $end_time); |
| 369 | - spip_log('JQ schedule end time ' . time(), 'jq' . _LOG_DEBUG); |
|
| 368 | + spip_log('JQ schedule end time '.time(), 'jq'._LOG_DEBUG); |
|
| 370 | 369 | |
| 371 | 370 | if ($row = array_shift($res)) { |
| 372 | 371 | queue_update_next_job_time(0); // on sait qu'il y a encore des jobs a lancer ASAP |
| 373 | - spip_log('JQ encore !', 'jq' . _LOG_DEBUG); |
|
| 372 | + spip_log('JQ encore !', 'jq'._LOG_DEBUG); |
|
| 374 | 373 | } else { |
| 375 | 374 | queue_update_next_job_time(); |
| 376 | 375 | } |
@@ -405,9 +404,9 @@ discard block |
||
| 405 | 404 | } |
| 406 | 405 | } |
| 407 | 406 | // purger ses liens eventuels avec des objets |
| 408 | - sql_delete('spip_jobs_liens', 'id_job=' . intval($row['id_job'])); |
|
| 407 | + sql_delete('spip_jobs_liens', 'id_job='.intval($row['id_job'])); |
|
| 409 | 408 | // supprimer le job fini |
| 410 | - sql_delete('spip_jobs', 'id_job=' . intval($row['id_job'])); |
|
| 409 | + sql_delete('spip_jobs', 'id_job='.intval($row['id_job'])); |
|
| 411 | 410 | } |
| 412 | 411 | |
| 413 | 412 | /** |
@@ -480,18 +479,18 @@ discard block |
||
| 480 | 479 | $res = sql_allfetsel( |
| 481 | 480 | '*', |
| 482 | 481 | 'spip_jobs', |
| 483 | - 'status=' . intval(_JQ_PENDING) . ' AND date<' . sql_quote(date('Y-m-d H:i:s', $time - 180)) |
|
| 482 | + 'status='.intval(_JQ_PENDING).' AND date<'.sql_quote(date('Y-m-d H:i:s', $time - 180)) |
|
| 484 | 483 | ); |
| 485 | 484 | if (is_array($res)) { |
| 486 | 485 | foreach ($res as $row) { |
| 487 | 486 | queue_close_job($row, $time); |
| 488 | - spip_log('queue_close_job car _JQ_PENDING depuis +180s : ' . print_r($row, 1), 'job_mort' . _LOG_ERREUR); |
|
| 487 | + spip_log('queue_close_job car _JQ_PENDING depuis +180s : '.print_r($row, 1), 'job_mort'._LOG_ERREUR); |
|
| 489 | 488 | } |
| 490 | 489 | } |
| 491 | 490 | |
| 492 | 491 | // chercher la date du prochain job si pas connu |
| 493 | 492 | if (is_null($next) or is_null(queue_sleep_time_to_next_job())) { |
| 494 | - $date = sql_getfetsel('date', 'spip_jobs', 'status=' . intval(_JQ_SCHEDULED), '', 'date', '0,1'); |
|
| 493 | + $date = sql_getfetsel('date', 'spip_jobs', 'status='.intval(_JQ_SCHEDULED), '', 'date', '0,1'); |
|
| 495 | 494 | $next = strtotime($date); |
| 496 | 495 | } |
| 497 | 496 | if (!is_null($next_time)) { |
@@ -504,7 +503,7 @@ discard block |
||
| 504 | 503 | if (is_null($nb_jobs_scheduled)) { |
| 505 | 504 | $nb_jobs_scheduled = sql_countsel( |
| 506 | 505 | 'spip_jobs', |
| 507 | - 'status=' . intval(_JQ_SCHEDULED) . ' AND date<' . sql_quote(date('Y-m-d H:i:s', $time)) |
|
| 506 | + 'status='.intval(_JQ_SCHEDULED).' AND date<'.sql_quote(date('Y-m-d H:i:s', $time)) |
|
| 508 | 507 | ); |
| 509 | 508 | } elseif ($next <= $time) { |
| 510 | 509 | $nb_jobs_scheduled++; |
@@ -573,7 +572,7 @@ discard block |
||
| 573 | 572 | } |
| 574 | 573 | |
| 575 | 574 | // ne pas relancer si on vient de lancer dans la meme seconde par un hit concurent |
| 576 | - if (file_exists($lock = _DIR_TMP . 'cron.lock') and !(@filemtime($lock) < $_SERVER['REQUEST_TIME'])) { |
|
| 575 | + if (file_exists($lock = _DIR_TMP.'cron.lock') and !(@filemtime($lock) < $_SERVER['REQUEST_TIME'])) { |
|
| 577 | 576 | return $texte; |
| 578 | 577 | } |
| 579 | 578 | |
@@ -645,7 +644,7 @@ discard block |
||
| 645 | 644 | $port = 80; |
| 646 | 645 | } |
| 647 | 646 | $fp = @fsockopen( |
| 648 | - $scheme . $parts['host'], |
|
| 647 | + $scheme.$parts['host'], |
|
| 649 | 648 | $parts['port'] ?? $port, |
| 650 | 649 | $errno, |
| 651 | 650 | $errstr, |
@@ -655,13 +654,13 @@ discard block |
||
| 655 | 654 | if ($fp) { |
| 656 | 655 | $host_sent = $parts['host']; |
| 657 | 656 | if (isset($parts['port']) and $parts['port'] !== $port) { |
| 658 | - $host_sent .= ':' . $parts['port']; |
|
| 657 | + $host_sent .= ':'.$parts['port']; |
|
| 659 | 658 | } |
| 660 | 659 | $timeout = 200; // ms |
| 661 | 660 | stream_set_timeout($fp, 0, $timeout * 1000); |
| 662 | - $query = $parts['path'] . ($parts['query'] ? '?' . $parts['query'] : ''); |
|
| 663 | - $out = 'GET ' . $query . " HTTP/1.1\r\n"; |
|
| 664 | - $out .= 'Host: ' . $host_sent . "\r\n"; |
|
| 661 | + $query = $parts['path'].($parts['query'] ? '?'.$parts['query'] : ''); |
|
| 662 | + $out = 'GET '.$query." HTTP/1.1\r\n"; |
|
| 663 | + $out .= 'Host: '.$host_sent."\r\n"; |
|
| 665 | 664 | $out .= "Connection: Close\r\n\r\n"; |
| 666 | 665 | fwrite($fp, $out); |
| 667 | 666 | spip_timer('read'); |
@@ -39,8 +39,7 @@ |
||
| 39 | 39 | } else { |
| 40 | 40 | $tls = true; |
| 41 | 41 | } |
| 42 | - } |
|
| 43 | - else { |
|
| 42 | + } else { |
|
| 44 | 43 | $tls_ldap == 'non'; |
| 45 | 44 | } |
| 46 | 45 | |
@@ -10,88 +10,88 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function install_etape_ldap2_dist() { |
| 17 | - $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 18 | - echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 19 | - |
|
| 20 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | - |
|
| 22 | - $port_ldap = _request('port_ldap'); |
|
| 23 | - |
|
| 24 | - $tls_ldap = _request('tls_ldap'); |
|
| 25 | - |
|
| 26 | - $protocole_ldap = _request('protocole_ldap'); |
|
| 27 | - |
|
| 28 | - $login_ldap = _request('login_ldap'); |
|
| 29 | - |
|
| 30 | - $pass_ldap = _request('pass_ldap'); |
|
| 31 | - |
|
| 32 | - $port_ldap = (int) $port_ldap; |
|
| 33 | - |
|
| 34 | - $tls = false; |
|
| 35 | - |
|
| 36 | - if ($tls_ldap == 'oui') { |
|
| 37 | - if ($port_ldap == 636) { |
|
| 38 | - $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 39 | - } else { |
|
| 40 | - $tls = true; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - else { |
|
| 44 | - $tls_ldap == 'non'; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - // Verifions que l'adresse demandee est valide |
|
| 48 | - $adresse_ldap = filter_var($adresse_ldap, FILTER_SANITIZE_URL) ?: ''; |
|
| 49 | - |
|
| 50 | - $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 51 | - $erreur = 'ldap_connect(' . spip_htmlspecialchars($adresse_ldap) . ', ' . spip_htmlspecialchars($port_ldap) . ')'; |
|
| 52 | - |
|
| 53 | - if ($ldap_link) { |
|
| 54 | - if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 55 | - $protocole_ldap = 2; |
|
| 56 | - ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 57 | - } |
|
| 58 | - if ($tls && !ldap_start_tls($ldap_link)) { |
|
| 59 | - $erreur = 'ldap_start_tls(' . spip_htmlspecialchars($ldap_link) |
|
| 60 | - . ' ' . spip_htmlspecialchars($adresse_ldap) |
|
| 61 | - . ', ' . spip_htmlspecialchars($port_ldap) . ')'; |
|
| 62 | - $ldap_link = false; |
|
| 63 | - } |
|
| 64 | - if ($ldap_link) { |
|
| 65 | - $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 66 | - $erreur = "ldap_bind('" . spip_htmlspecialchars($ldap_link) |
|
| 67 | - . "', '" . spip_htmlspecialchars($login_ldap) |
|
| 68 | - . "', '" . spip_htmlspecialchars($pass_ldap) |
|
| 69 | - . "'): " . spip_htmlspecialchars($adresse_ldap) |
|
| 70 | - . ', ' . spip_htmlspecialchars($port_ldap); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if ($ldap_link) { |
|
| 75 | - echo info_etape( |
|
| 76 | - _T('titre_connexion_ldap'), |
|
| 77 | - info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 78 | - ), _T('info_connexion_ldap_ok'); |
|
| 79 | - echo generer_form_ecrire('install', ( |
|
| 80 | - "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 81 | - . "\n<input type='hidden' name='adresse_ldap' value=\"" . spip_htmlspecialchars($adresse_ldap) . '" />' |
|
| 82 | - . "\n<input type='hidden' name='port_ldap' value=\"" . spip_htmlspecialchars($port_ldap) . '" />' |
|
| 83 | - . "\n<input type='hidden' name='login_ldap' value=\"" . spip_htmlspecialchars($login_ldap) . '" />' |
|
| 84 | - . "\n<input type='hidden' name='pass_ldap' value=\"" . spip_htmlspecialchars($pass_ldap) . '" />' |
|
| 85 | - . "\n<input type='hidden' name='protocole_ldap' value=\"" . spip_htmlspecialchars($protocole_ldap) . '" />' |
|
| 86 | - . "\n<input type='hidden' name='tls_ldap' value=\"" . spip_htmlspecialchars($tls_ldap) . '" />' |
|
| 87 | - . bouton_suivant())); |
|
| 88 | - } else { |
|
| 89 | - echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 90 | - "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 91 | - '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 92 | - "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 93 | - '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - echo $minipage->installFinPage(); |
|
| 17 | + $minipage = new Spip\Afficher\Minipage\Installation(); |
|
| 18 | + echo $minipage->installDebutPage(['onload' => 'document.getElementById(\'suivant\').focus();return false;']); |
|
| 19 | + |
|
| 20 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | + |
|
| 22 | + $port_ldap = _request('port_ldap'); |
|
| 23 | + |
|
| 24 | + $tls_ldap = _request('tls_ldap'); |
|
| 25 | + |
|
| 26 | + $protocole_ldap = _request('protocole_ldap'); |
|
| 27 | + |
|
| 28 | + $login_ldap = _request('login_ldap'); |
|
| 29 | + |
|
| 30 | + $pass_ldap = _request('pass_ldap'); |
|
| 31 | + |
|
| 32 | + $port_ldap = (int) $port_ldap; |
|
| 33 | + |
|
| 34 | + $tls = false; |
|
| 35 | + |
|
| 36 | + if ($tls_ldap == 'oui') { |
|
| 37 | + if ($port_ldap == 636) { |
|
| 38 | + $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 39 | + } else { |
|
| 40 | + $tls = true; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + else { |
|
| 44 | + $tls_ldap == 'non'; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + // Verifions que l'adresse demandee est valide |
|
| 48 | + $adresse_ldap = filter_var($adresse_ldap, FILTER_SANITIZE_URL) ?: ''; |
|
| 49 | + |
|
| 50 | + $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 51 | + $erreur = 'ldap_connect(' . spip_htmlspecialchars($adresse_ldap) . ', ' . spip_htmlspecialchars($port_ldap) . ')'; |
|
| 52 | + |
|
| 53 | + if ($ldap_link) { |
|
| 54 | + if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 55 | + $protocole_ldap = 2; |
|
| 56 | + ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 57 | + } |
|
| 58 | + if ($tls && !ldap_start_tls($ldap_link)) { |
|
| 59 | + $erreur = 'ldap_start_tls(' . spip_htmlspecialchars($ldap_link) |
|
| 60 | + . ' ' . spip_htmlspecialchars($adresse_ldap) |
|
| 61 | + . ', ' . spip_htmlspecialchars($port_ldap) . ')'; |
|
| 62 | + $ldap_link = false; |
|
| 63 | + } |
|
| 64 | + if ($ldap_link) { |
|
| 65 | + $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 66 | + $erreur = "ldap_bind('" . spip_htmlspecialchars($ldap_link) |
|
| 67 | + . "', '" . spip_htmlspecialchars($login_ldap) |
|
| 68 | + . "', '" . spip_htmlspecialchars($pass_ldap) |
|
| 69 | + . "'): " . spip_htmlspecialchars($adresse_ldap) |
|
| 70 | + . ', ' . spip_htmlspecialchars($port_ldap); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if ($ldap_link) { |
|
| 75 | + echo info_etape( |
|
| 76 | + _T('titre_connexion_ldap'), |
|
| 77 | + info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 78 | + ), _T('info_connexion_ldap_ok'); |
|
| 79 | + echo generer_form_ecrire('install', ( |
|
| 80 | + "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 81 | + . "\n<input type='hidden' name='adresse_ldap' value=\"" . spip_htmlspecialchars($adresse_ldap) . '" />' |
|
| 82 | + . "\n<input type='hidden' name='port_ldap' value=\"" . spip_htmlspecialchars($port_ldap) . '" />' |
|
| 83 | + . "\n<input type='hidden' name='login_ldap' value=\"" . spip_htmlspecialchars($login_ldap) . '" />' |
|
| 84 | + . "\n<input type='hidden' name='pass_ldap' value=\"" . spip_htmlspecialchars($pass_ldap) . '" />' |
|
| 85 | + . "\n<input type='hidden' name='protocole_ldap' value=\"" . spip_htmlspecialchars($protocole_ldap) . '" />' |
|
| 86 | + . "\n<input type='hidden' name='tls_ldap' value=\"" . spip_htmlspecialchars($tls_ldap) . '" />' |
|
| 87 | + . bouton_suivant())); |
|
| 88 | + } else { |
|
| 89 | + echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 90 | + "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 91 | + '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 92 | + "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 93 | + '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + echo $minipage->installFinPage(); |
|
| 97 | 97 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $adresse_ldap = filter_var($adresse_ldap, FILTER_SANITIZE_URL) ?: ''; |
| 49 | 49 | |
| 50 | 50 | $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
| 51 | - $erreur = 'ldap_connect(' . spip_htmlspecialchars($adresse_ldap) . ', ' . spip_htmlspecialchars($port_ldap) . ')'; |
|
| 51 | + $erreur = 'ldap_connect('.spip_htmlspecialchars($adresse_ldap).', '.spip_htmlspecialchars($port_ldap).')'; |
|
| 52 | 52 | |
| 53 | 53 | if ($ldap_link) { |
| 54 | 54 | if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
@@ -56,18 +56,18 @@ discard block |
||
| 56 | 56 | ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
| 57 | 57 | } |
| 58 | 58 | if ($tls && !ldap_start_tls($ldap_link)) { |
| 59 | - $erreur = 'ldap_start_tls(' . spip_htmlspecialchars($ldap_link) |
|
| 60 | - . ' ' . spip_htmlspecialchars($adresse_ldap) |
|
| 61 | - . ', ' . spip_htmlspecialchars($port_ldap) . ')'; |
|
| 59 | + $erreur = 'ldap_start_tls('.spip_htmlspecialchars($ldap_link) |
|
| 60 | + . ' '.spip_htmlspecialchars($adresse_ldap) |
|
| 61 | + . ', '.spip_htmlspecialchars($port_ldap).')'; |
|
| 62 | 62 | $ldap_link = false; |
| 63 | 63 | } |
| 64 | 64 | if ($ldap_link) { |
| 65 | 65 | $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
| 66 | - $erreur = "ldap_bind('" . spip_htmlspecialchars($ldap_link) |
|
| 67 | - . "', '" . spip_htmlspecialchars($login_ldap) |
|
| 68 | - . "', '" . spip_htmlspecialchars($pass_ldap) |
|
| 69 | - . "'): " . spip_htmlspecialchars($adresse_ldap) |
|
| 70 | - . ', ' . spip_htmlspecialchars($port_ldap); |
|
| 66 | + $erreur = "ldap_bind('".spip_htmlspecialchars($ldap_link) |
|
| 67 | + . "', '".spip_htmlspecialchars($login_ldap) |
|
| 68 | + . "', '".spip_htmlspecialchars($pass_ldap) |
|
| 69 | + . "'): ".spip_htmlspecialchars($adresse_ldap) |
|
| 70 | + . ', '.spip_htmlspecialchars($port_ldap); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
@@ -75,22 +75,22 @@ discard block |
||
| 75 | 75 | echo info_etape( |
| 76 | 76 | _T('titre_connexion_ldap'), |
| 77 | 77 | info_progression_etape(2, 'etape_ldap', 'install/') |
| 78 | - ), _T('info_connexion_ldap_ok'); |
|
| 78 | + ), _T('info_connexion_ldap_ok'); |
|
| 79 | 79 | echo generer_form_ecrire('install', ( |
| 80 | 80 | "\n<input type='hidden' name='etape' value='ldap3' />" |
| 81 | - . "\n<input type='hidden' name='adresse_ldap' value=\"" . spip_htmlspecialchars($adresse_ldap) . '" />' |
|
| 82 | - . "\n<input type='hidden' name='port_ldap' value=\"" . spip_htmlspecialchars($port_ldap) . '" />' |
|
| 83 | - . "\n<input type='hidden' name='login_ldap' value=\"" . spip_htmlspecialchars($login_ldap) . '" />' |
|
| 84 | - . "\n<input type='hidden' name='pass_ldap' value=\"" . spip_htmlspecialchars($pass_ldap) . '" />' |
|
| 85 | - . "\n<input type='hidden' name='protocole_ldap' value=\"" . spip_htmlspecialchars($protocole_ldap) . '" />' |
|
| 86 | - . "\n<input type='hidden' name='tls_ldap' value=\"" . spip_htmlspecialchars($tls_ldap) . '" />' |
|
| 81 | + . "\n<input type='hidden' name='adresse_ldap' value=\"".spip_htmlspecialchars($adresse_ldap).'" />' |
|
| 82 | + . "\n<input type='hidden' name='port_ldap' value=\"".spip_htmlspecialchars($port_ldap).'" />' |
|
| 83 | + . "\n<input type='hidden' name='login_ldap' value=\"".spip_htmlspecialchars($login_ldap).'" />' |
|
| 84 | + . "\n<input type='hidden' name='pass_ldap' value=\"".spip_htmlspecialchars($pass_ldap).'" />' |
|
| 85 | + . "\n<input type='hidden' name='protocole_ldap' value=\"".spip_htmlspecialchars($protocole_ldap).'" />' |
|
| 86 | + . "\n<input type='hidden' name='tls_ldap' value=\"".spip_htmlspecialchars($tls_ldap).'" />' |
|
| 87 | 87 | . bouton_suivant())); |
| 88 | 88 | } else { |
| 89 | 89 | echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
| 90 | - "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 91 | - '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 92 | - "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 93 | - '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 90 | + "<div class='error'><p>"._T('avis_connexion_ldap_echec_1').'</p>', |
|
| 91 | + '<p>'._T('avis_connexion_ldap_echec_2'). |
|
| 92 | + "<br />\n"._T('avis_connexion_ldap_echec_3'). |
|
| 93 | + '<br /><br />'.$erreur.'<b> ?</b></p></div>'; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | echo $minipage->installFinPage(); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $id_rubrique, |
| 151 | 151 | [ |
| 152 | 152 | 'data' => $set, |
| 153 | - 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 153 | + 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique').' '._T('info_numero_abbreviation').$id_rubrique] |
|
| 154 | 154 | ], |
| 155 | 155 | $c |
| 156 | 156 | ) |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | ) |
| 255 | 255 | ) { |
| 256 | 256 | if ($s['statut'] != 'prepa') { |
| 257 | - spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 257 | + spip_log("deplacement de $id_rubrique vers $id_parent refuse a ".$GLOBALS['visiteur_session']['id_auteur'].' '.$GLOBALS['visiteur_session']['statut']); |
|
| 258 | 258 | } |
| 259 | 259 | } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
| 260 | 260 | $statut_ancien = $s['statut']; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Rubriques\Edition |
| 16 | 16 | */ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/rubriques'); |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function action_editer_rubrique_dist($arg = null) { |
| 39 | 39 | |
| 40 | - if (is_null($arg)) { |
|
| 41 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 42 | - $arg = $securiser_action(); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - if (!$id_rubrique = (int) $arg) { |
|
| 46 | - if ($arg != 'oui') { |
|
| 47 | - include_spip('inc/headers'); |
|
| 48 | - redirige_url_ecrire(); |
|
| 49 | - } |
|
| 50 | - $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - $err = rubrique_modifier($id_rubrique); |
|
| 54 | - |
|
| 55 | - if (_request('redirect')) { |
|
| 56 | - $redirect = parametre_url( |
|
| 57 | - urldecode((string) _request('redirect')), |
|
| 58 | - 'id_rubrique', |
|
| 59 | - $id_rubrique, |
|
| 60 | - '&' |
|
| 61 | - ); |
|
| 62 | - |
|
| 63 | - include_spip('inc/headers'); |
|
| 64 | - redirige_par_entete($redirect); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - return [$id_rubrique, $err]; |
|
| 40 | + if (is_null($arg)) { |
|
| 41 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 42 | + $arg = $securiser_action(); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + if (!$id_rubrique = (int) $arg) { |
|
| 46 | + if ($arg != 'oui') { |
|
| 47 | + include_spip('inc/headers'); |
|
| 48 | + redirige_url_ecrire(); |
|
| 49 | + } |
|
| 50 | + $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + $err = rubrique_modifier($id_rubrique); |
|
| 54 | + |
|
| 55 | + if (_request('redirect')) { |
|
| 56 | + $redirect = parametre_url( |
|
| 57 | + urldecode((string) _request('redirect')), |
|
| 58 | + 'id_rubrique', |
|
| 59 | + $id_rubrique, |
|
| 60 | + '&' |
|
| 61 | + ); |
|
| 62 | + |
|
| 63 | + include_spip('inc/headers'); |
|
| 64 | + redirige_par_entete($redirect); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + return [$id_rubrique, $err]; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -79,64 +79,64 @@ discard block |
||
| 79 | 79 | * Identifiant de la rubrique crée |
| 80 | 80 | */ |
| 81 | 81 | function rubrique_inserer($id_parent, $set = null) { |
| 82 | - $champs = [ |
|
| 83 | - 'titre' => _T('item_nouvelle_rubrique'), |
|
| 84 | - 'id_parent' => (int) $id_parent, |
|
| 85 | - 'statut' => 'prepa' |
|
| 86 | - ]; |
|
| 87 | - |
|
| 88 | - if ($set) { |
|
| 89 | - $champs = array_merge($champs, $set); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // Envoyer aux plugins |
|
| 93 | - $champs = pipeline( |
|
| 94 | - 'pre_insertion', |
|
| 95 | - [ |
|
| 96 | - 'args' => [ |
|
| 97 | - 'table' => 'spip_rubriques', |
|
| 98 | - ], |
|
| 99 | - 'data' => $champs |
|
| 100 | - ] |
|
| 101 | - ); |
|
| 102 | - |
|
| 103 | - $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 104 | - pipeline( |
|
| 105 | - 'post_insertion', |
|
| 106 | - [ |
|
| 107 | - 'args' => [ |
|
| 108 | - 'table' => 'spip_rubriques', |
|
| 109 | - 'id_objet' => $id_rubrique |
|
| 110 | - ], |
|
| 111 | - 'data' => $champs |
|
| 112 | - ] |
|
| 113 | - ); |
|
| 114 | - propager_les_secteurs(); |
|
| 115 | - calculer_langues_rubriques(); |
|
| 116 | - |
|
| 117 | - // Appeler une notification |
|
| 118 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 119 | - $notifications( |
|
| 120 | - 'rubrique_inserer', |
|
| 121 | - $id_rubrique, |
|
| 122 | - [ |
|
| 123 | - 'id_parent' => $id_parent, |
|
| 124 | - 'champs' => $champs, |
|
| 125 | - ] |
|
| 126 | - ); |
|
| 127 | - $notifications( |
|
| 128 | - 'objet_inserer', |
|
| 129 | - $id_rubrique, |
|
| 130 | - [ |
|
| 131 | - 'objet' => 'rubrique', |
|
| 132 | - 'id_objet' => $id_rubrique, |
|
| 133 | - 'id_parent' => $id_parent, |
|
| 134 | - 'champs' => $champs, |
|
| 135 | - ] |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return $id_rubrique; |
|
| 82 | + $champs = [ |
|
| 83 | + 'titre' => _T('item_nouvelle_rubrique'), |
|
| 84 | + 'id_parent' => (int) $id_parent, |
|
| 85 | + 'statut' => 'prepa' |
|
| 86 | + ]; |
|
| 87 | + |
|
| 88 | + if ($set) { |
|
| 89 | + $champs = array_merge($champs, $set); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // Envoyer aux plugins |
|
| 93 | + $champs = pipeline( |
|
| 94 | + 'pre_insertion', |
|
| 95 | + [ |
|
| 96 | + 'args' => [ |
|
| 97 | + 'table' => 'spip_rubriques', |
|
| 98 | + ], |
|
| 99 | + 'data' => $champs |
|
| 100 | + ] |
|
| 101 | + ); |
|
| 102 | + |
|
| 103 | + $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 104 | + pipeline( |
|
| 105 | + 'post_insertion', |
|
| 106 | + [ |
|
| 107 | + 'args' => [ |
|
| 108 | + 'table' => 'spip_rubriques', |
|
| 109 | + 'id_objet' => $id_rubrique |
|
| 110 | + ], |
|
| 111 | + 'data' => $champs |
|
| 112 | + ] |
|
| 113 | + ); |
|
| 114 | + propager_les_secteurs(); |
|
| 115 | + calculer_langues_rubriques(); |
|
| 116 | + |
|
| 117 | + // Appeler une notification |
|
| 118 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 119 | + $notifications( |
|
| 120 | + 'rubrique_inserer', |
|
| 121 | + $id_rubrique, |
|
| 122 | + [ |
|
| 123 | + 'id_parent' => $id_parent, |
|
| 124 | + 'champs' => $champs, |
|
| 125 | + ] |
|
| 126 | + ); |
|
| 127 | + $notifications( |
|
| 128 | + 'objet_inserer', |
|
| 129 | + $id_rubrique, |
|
| 130 | + [ |
|
| 131 | + 'objet' => 'rubrique', |
|
| 132 | + 'id_objet' => $id_rubrique, |
|
| 133 | + 'id_parent' => $id_parent, |
|
| 134 | + 'champs' => $champs, |
|
| 135 | + ] |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + return $id_rubrique; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -152,46 +152,46 @@ discard block |
||
| 152 | 152 | * - chaîne : texte d'un message d'erreur |
| 153 | 153 | */ |
| 154 | 154 | function rubrique_modifier($id_rubrique, $set = null) { |
| 155 | - include_spip('inc/autoriser'); |
|
| 156 | - include_spip('inc/filtres'); |
|
| 157 | - |
|
| 158 | - include_spip('inc/modifier'); |
|
| 159 | - $c = collecter_requests( |
|
| 160 | - // include list |
|
| 161 | - objet_info('rubrique', 'champs_editables'), |
|
| 162 | - // exclude list |
|
| 163 | - ['id_parent', 'confirme_deplace'], |
|
| 164 | - // donnees eventuellement fournies |
|
| 165 | - $set |
|
| 166 | - ); |
|
| 167 | - |
|
| 168 | - if ( |
|
| 169 | - $err = objet_modifier_champs( |
|
| 170 | - 'rubrique', |
|
| 171 | - $id_rubrique, |
|
| 172 | - [ |
|
| 173 | - 'data' => $set, |
|
| 174 | - 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 175 | - ], |
|
| 176 | - $c |
|
| 177 | - ) |
|
| 178 | - ) { |
|
| 179 | - return $err; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 183 | - // Deplacer la rubrique |
|
| 184 | - if (isset($c['id_parent'])) { |
|
| 185 | - $err = rubrique_instituer($id_rubrique, $c); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // invalider les caches marques de cette rubrique |
|
| 189 | - include_spip('inc/invalideur'); |
|
| 190 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 191 | - // et celui de menu_rubriques |
|
| 192 | - effacer_meta('date_calcul_rubriques'); |
|
| 193 | - |
|
| 194 | - return $err; |
|
| 155 | + include_spip('inc/autoriser'); |
|
| 156 | + include_spip('inc/filtres'); |
|
| 157 | + |
|
| 158 | + include_spip('inc/modifier'); |
|
| 159 | + $c = collecter_requests( |
|
| 160 | + // include list |
|
| 161 | + objet_info('rubrique', 'champs_editables'), |
|
| 162 | + // exclude list |
|
| 163 | + ['id_parent', 'confirme_deplace'], |
|
| 164 | + // donnees eventuellement fournies |
|
| 165 | + $set |
|
| 166 | + ); |
|
| 167 | + |
|
| 168 | + if ( |
|
| 169 | + $err = objet_modifier_champs( |
|
| 170 | + 'rubrique', |
|
| 171 | + $id_rubrique, |
|
| 172 | + [ |
|
| 173 | + 'data' => $set, |
|
| 174 | + 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 175 | + ], |
|
| 176 | + $c |
|
| 177 | + ) |
|
| 178 | + ) { |
|
| 179 | + return $err; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 183 | + // Deplacer la rubrique |
|
| 184 | + if (isset($c['id_parent'])) { |
|
| 185 | + $err = rubrique_instituer($id_rubrique, $c); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // invalider les caches marques de cette rubrique |
|
| 189 | + include_spip('inc/invalideur'); |
|
| 190 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 191 | + // et celui de menu_rubriques |
|
| 192 | + effacer_meta('date_calcul_rubriques'); |
|
| 193 | + |
|
| 194 | + return $err; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -214,29 +214,29 @@ discard block |
||
| 214 | 214 | * false si la confirmation du déplacement n'est pas présente |
| 215 | 215 | */ |
| 216 | 216 | function editer_rubrique_breves($id_rubrique, $id_parent, $c = []) { |
| 217 | - if (!sql_table_exists('spip_breves')) { |
|
| 218 | - return true; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 222 | - return true; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - if (empty($c['confirme_deplace']) || $c['confirme_deplace'] != 'oui') { |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if ( |
|
| 230 | - $id_secteur = sql_getfetsel( |
|
| 231 | - 'id_secteur', |
|
| 232 | - 'spip_rubriques', |
|
| 233 | - "id_rubrique=$id_parent" |
|
| 234 | - ) |
|
| 235 | - ) { |
|
| 236 | - sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - return true; |
|
| 217 | + if (!sql_table_exists('spip_breves')) { |
|
| 218 | + return true; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 222 | + return true; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + if (empty($c['confirme_deplace']) || $c['confirme_deplace'] != 'oui') { |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if ( |
|
| 230 | + $id_secteur = sql_getfetsel( |
|
| 231 | + 'id_secteur', |
|
| 232 | + 'spip_rubriques', |
|
| 233 | + "id_rubrique=$id_parent" |
|
| 234 | + ) |
|
| 235 | + ) { |
|
| 236 | + sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + return true; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -258,72 +258,72 @@ discard block |
||
| 258 | 258 | * Chaîne : texte du message d'erreur |
| 259 | 259 | */ |
| 260 | 260 | function rubrique_instituer($id_rubrique, $c) { |
| 261 | - // traitement de la rubrique parente |
|
| 262 | - // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 263 | - // qu'on n'administre pas. |
|
| 264 | - |
|
| 265 | - if (null !== ($id_parent = $c['id_parent'])) { |
|
| 266 | - $id_parent = (int) $id_parent; |
|
| 267 | - $filles = calcul_branche_in($id_rubrique); |
|
| 268 | - if (str_contains(",$id_parent,", (string) ",$filles,")) { |
|
| 269 | - spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 270 | - } else { |
|
| 271 | - $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 272 | - $old_parent = $s['id_parent']; |
|
| 273 | - |
|
| 274 | - if ( |
|
| 275 | - !($id_parent != $old_parent |
|
| 276 | - && autoriser('publierdans', 'rubrique', $id_parent) |
|
| 277 | - && autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 278 | - && autoriser('publierdans', 'rubrique', $old_parent) |
|
| 279 | - ) |
|
| 280 | - ) { |
|
| 281 | - if ($s['statut'] != 'prepa') { |
|
| 282 | - spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 283 | - } |
|
| 284 | - } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 285 | - $statut_ancien = $s['statut']; |
|
| 286 | - sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - propager_les_secteurs(); |
|
| 290 | - |
|
| 291 | - // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 292 | - if ($statut_ancien == 'publie') { |
|
| 293 | - calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 294 | - } |
|
| 295 | - // Creation ou deplacement d'une rubrique non publiee |
|
| 296 | - // invalider le cache de leur menu |
|
| 297 | - elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 298 | - effacer_meta('date_calcul_rubriques'); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - calculer_langues_rubriques(); |
|
| 302 | - |
|
| 303 | - // Appeler une notification |
|
| 304 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 305 | - $notifications( |
|
| 306 | - 'rubrique_instituer', |
|
| 307 | - $id_rubrique, |
|
| 308 | - [ |
|
| 309 | - 'statut_ancien' => $statut_ancien, |
|
| 310 | - 'id_parent_ancien' => $old_parent, |
|
| 311 | - ] |
|
| 312 | - ); |
|
| 313 | - $notifications( |
|
| 314 | - 'objet_instituer', |
|
| 315 | - $id_rubrique, |
|
| 316 | - [ |
|
| 317 | - 'objet' => 'rubrique', |
|
| 318 | - 'id_objet' => $id_rubrique, |
|
| 319 | - 'statut_ancien' => $statut_ancien, |
|
| 320 | - 'id_parent_ancien' => $old_parent, |
|
| 321 | - ] |
|
| 322 | - ); |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - return ''; // pas d'erreur |
|
| 261 | + // traitement de la rubrique parente |
|
| 262 | + // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 263 | + // qu'on n'administre pas. |
|
| 264 | + |
|
| 265 | + if (null !== ($id_parent = $c['id_parent'])) { |
|
| 266 | + $id_parent = (int) $id_parent; |
|
| 267 | + $filles = calcul_branche_in($id_rubrique); |
|
| 268 | + if (str_contains(",$id_parent,", (string) ",$filles,")) { |
|
| 269 | + spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 270 | + } else { |
|
| 271 | + $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 272 | + $old_parent = $s['id_parent']; |
|
| 273 | + |
|
| 274 | + if ( |
|
| 275 | + !($id_parent != $old_parent |
|
| 276 | + && autoriser('publierdans', 'rubrique', $id_parent) |
|
| 277 | + && autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 278 | + && autoriser('publierdans', 'rubrique', $old_parent) |
|
| 279 | + ) |
|
| 280 | + ) { |
|
| 281 | + if ($s['statut'] != 'prepa') { |
|
| 282 | + spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 283 | + } |
|
| 284 | + } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 285 | + $statut_ancien = $s['statut']; |
|
| 286 | + sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + propager_les_secteurs(); |
|
| 290 | + |
|
| 291 | + // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 292 | + if ($statut_ancien == 'publie') { |
|
| 293 | + calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 294 | + } |
|
| 295 | + // Creation ou deplacement d'une rubrique non publiee |
|
| 296 | + // invalider le cache de leur menu |
|
| 297 | + elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 298 | + effacer_meta('date_calcul_rubriques'); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + calculer_langues_rubriques(); |
|
| 302 | + |
|
| 303 | + // Appeler une notification |
|
| 304 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 305 | + $notifications( |
|
| 306 | + 'rubrique_instituer', |
|
| 307 | + $id_rubrique, |
|
| 308 | + [ |
|
| 309 | + 'statut_ancien' => $statut_ancien, |
|
| 310 | + 'id_parent_ancien' => $old_parent, |
|
| 311 | + ] |
|
| 312 | + ); |
|
| 313 | + $notifications( |
|
| 314 | + 'objet_instituer', |
|
| 315 | + $id_rubrique, |
|
| 316 | + [ |
|
| 317 | + 'objet' => 'rubrique', |
|
| 318 | + 'id_objet' => $id_rubrique, |
|
| 319 | + 'statut_ancien' => $statut_ancien, |
|
| 320 | + 'id_parent_ancien' => $old_parent, |
|
| 321 | + ] |
|
| 322 | + ); |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + return ''; // pas d'erreur |
|
| 329 | 329 | } |
@@ -312,8 +312,7 @@ |
||
| 312 | 312 | ecrire_meta($casier, $serialized_store, null, $table); |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | - } |
|
| 316 | - else { |
|
| 315 | + } else { |
|
| 317 | 316 | ecrire_meta($casier, $store, null, $table); |
| 318 | 317 | } |
| 319 | 318 | } |
@@ -303,9 +303,9 @@ |
||
| 303 | 303 | // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine |
| 304 | 304 | // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4) |
| 305 | 305 | if ($has_planes) { |
| 306 | - $check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier)); |
|
| 306 | + $check_store = sql_getfetsel('valeur', 'spip_'.$table, 'nom='.sql_quote($casier)); |
|
| 307 | 307 | if ($check_store !== $serialized_store) { |
| 308 | - array_walk_recursive($store, function (&$value, $key) { |
|
| 308 | + array_walk_recursive($store, function(&$value, $key) { |
|
| 309 | 309 | if (is_string($value)) { |
| 310 | 310 | $value = utf8_noplanes($value); |
| 311 | 311 | } |
@@ -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 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | 29 | function inc_config_dist() { |
| 30 | - actualise_metas(liste_metas()); |
|
| 30 | + actualise_metas(liste_metas()); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -44,32 +44,32 @@ discard block |
||
| 44 | 44 | * Liste (table, casier, sous_casier) |
| 45 | 45 | */ |
| 46 | 46 | function expliquer_config($cfg) { |
| 47 | - // par defaut, sur la table des meta |
|
| 48 | - $table = 'meta'; |
|
| 49 | - $casier = null; |
|
| 50 | - $sous_casier = []; |
|
| 51 | - $cfg = explode('/', $cfg); |
|
| 52 | - |
|
| 53 | - // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 54 | - if (!reset($cfg) && count($cfg) > 1) { |
|
| 55 | - array_shift($cfg); |
|
| 56 | - $table = array_shift($cfg); |
|
| 57 | - if (!isset($GLOBALS[$table])) { |
|
| 58 | - lire_metas($table); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 63 | - // pas sur un appel vide '' |
|
| 64 | - if (count($cfg) && '' !== ($c = array_shift($cfg))) { |
|
| 65 | - $casier = $c; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - if ($cfg !== []) { |
|
| 69 | - $sous_casier = $cfg; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return [$table, $casier, $sous_casier]; |
|
| 47 | + // par defaut, sur la table des meta |
|
| 48 | + $table = 'meta'; |
|
| 49 | + $casier = null; |
|
| 50 | + $sous_casier = []; |
|
| 51 | + $cfg = explode('/', $cfg); |
|
| 52 | + |
|
| 53 | + // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 54 | + if (!reset($cfg) && count($cfg) > 1) { |
|
| 55 | + array_shift($cfg); |
|
| 56 | + $table = array_shift($cfg); |
|
| 57 | + if (!isset($GLOBALS[$table])) { |
|
| 58 | + lire_metas($table); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 63 | + // pas sur un appel vide '' |
|
| 64 | + if (count($cfg) && '' !== ($c = array_shift($cfg))) { |
|
| 65 | + $casier = $c; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + if ($cfg !== []) { |
|
| 69 | + $sous_casier = $cfg; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return [$table, $casier, $sous_casier]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -97,63 +97,63 @@ discard block |
||
| 97 | 97 | * Contenu de la configuration obtenue |
| 98 | 98 | */ |
| 99 | 99 | function lire_config($cfg = '', mixed $def = null, $unserialize = true) { |
| 100 | - // lire le stockage sous la forme /table/valeur |
|
| 101 | - // ou valeur qui est en fait implicitement /meta/valeur |
|
| 102 | - // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 103 | - |
|
| 104 | - // traiter en priorite le cas simple et frequent |
|
| 105 | - // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 106 | - if ($cfg && strpbrk($cfg, '/:') === false) { |
|
| 107 | - return isset($GLOBALS['meta'][$cfg]) |
|
| 108 | - ? (!$unserialize |
|
| 109 | - // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 110 | - || !is_string($GLOBALS['meta'][$cfg]) |
|
| 111 | - // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 112 | - || !str_contains($GLOBALS['meta'][$cfg], ':') |
|
| 113 | - || ($t = @unserialize($GLOBALS['meta'][$cfg])) === false ? $GLOBALS['meta'][$cfg] : $t) |
|
| 114 | - : $def; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // Brancher sur methodes externes si besoin |
|
| 118 | - if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 119 | - $methode = substr($cfg, 0, $p); |
|
| 120 | - $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 121 | - |
|
| 122 | - return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 126 | - |
|
| 127 | - if (!isset($GLOBALS[$table])) { |
|
| 128 | - return $def; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $r = $GLOBALS[$table]; |
|
| 132 | - |
|
| 133 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 134 | - if (!$casier) { |
|
| 135 | - return $unserialize ? $r : serialize($r); |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - // casier principal : |
|
| 139 | - // le deserializer si demande |
|
| 140 | - // ou si on a besoin |
|
| 141 | - // d'un sous casier |
|
| 142 | - $r = $r[$casier] ?? null; |
|
| 143 | - if (($unserialize || (is_countable($sous_casier) ? count($sous_casier) : 0)) && $r && is_string($r)) { |
|
| 144 | - $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // aller chercher le sous_casier |
|
| 148 | - while (!is_null($r) && ($casier = array_shift($sous_casier))) { |
|
| 149 | - $r = $r[$casier] ?? null; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if (is_null($r)) { |
|
| 153 | - return $def; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - return $r; |
|
| 100 | + // lire le stockage sous la forme /table/valeur |
|
| 101 | + // ou valeur qui est en fait implicitement /meta/valeur |
|
| 102 | + // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 103 | + |
|
| 104 | + // traiter en priorite le cas simple et frequent |
|
| 105 | + // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 106 | + if ($cfg && strpbrk($cfg, '/:') === false) { |
|
| 107 | + return isset($GLOBALS['meta'][$cfg]) |
|
| 108 | + ? (!$unserialize |
|
| 109 | + // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 110 | + || !is_string($GLOBALS['meta'][$cfg]) |
|
| 111 | + // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 112 | + || !str_contains($GLOBALS['meta'][$cfg], ':') |
|
| 113 | + || ($t = @unserialize($GLOBALS['meta'][$cfg])) === false ? $GLOBALS['meta'][$cfg] : $t) |
|
| 114 | + : $def; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // Brancher sur methodes externes si besoin |
|
| 118 | + if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 119 | + $methode = substr($cfg, 0, $p); |
|
| 120 | + $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 121 | + |
|
| 122 | + return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 126 | + |
|
| 127 | + if (!isset($GLOBALS[$table])) { |
|
| 128 | + return $def; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $r = $GLOBALS[$table]; |
|
| 132 | + |
|
| 133 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 134 | + if (!$casier) { |
|
| 135 | + return $unserialize ? $r : serialize($r); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + // casier principal : |
|
| 139 | + // le deserializer si demande |
|
| 140 | + // ou si on a besoin |
|
| 141 | + // d'un sous casier |
|
| 142 | + $r = $r[$casier] ?? null; |
|
| 143 | + if (($unserialize || (is_countable($sous_casier) ? count($sous_casier) : 0)) && $r && is_string($r)) { |
|
| 144 | + $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // aller chercher le sous_casier |
|
| 148 | + while (!is_null($r) && ($casier = array_shift($sous_casier))) { |
|
| 149 | + $r = $r[$casier] ?? null; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if (is_null($r)) { |
|
| 153 | + return $def; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + return $r; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @return mixed |
| 167 | 167 | */ |
| 168 | 168 | function lire_config_metapack_dist($cfg = '', mixed $def = null, $unserialize = true) { |
| 169 | - return lire_config($cfg, $def, $unserialize); |
|
| 169 | + return lire_config($cfg, $def, $unserialize); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -177,144 +177,144 @@ discard block |
||
| 177 | 177 | * @return bool |
| 178 | 178 | */ |
| 179 | 179 | function ecrire_config($cfg, mixed $store) { |
| 180 | - // Brancher sur methodes externes si besoin |
|
| 181 | - if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 182 | - $methode = substr($cfg, 0, $p); |
|
| 183 | - $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 184 | - |
|
| 185 | - return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 189 | - // il faut au moins un casier pour ecrire |
|
| 190 | - if (!$casier) { |
|
| 191 | - return false; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - // trouvons ou creons le pointeur sur le casier |
|
| 195 | - $st = $GLOBALS[$table][$casier] ?? null; |
|
| 196 | - if (!is_array($st) && ($sous_casier || is_array($store))) { |
|
| 197 | - if ($st === null) { |
|
| 198 | - // ne rien creer si c'est une demande d'effacement |
|
| 199 | - if ($store === null) { |
|
| 200 | - return false; |
|
| 201 | - } |
|
| 202 | - $st = []; |
|
| 203 | - } else { |
|
| 204 | - $st = unserialize($st); |
|
| 205 | - if ($st === false) { |
|
| 206 | - // ne rien creer si c'est une demande d'effacement |
|
| 207 | - if ($store === null) { |
|
| 208 | - return false; |
|
| 209 | - } |
|
| 210 | - $st = []; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $has_planes = false; |
|
| 216 | - // si on a affaire a un sous caiser |
|
| 217 | - // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 218 | - if ($c = $sous_casier) { |
|
| 219 | - $sc = &$st; |
|
| 220 | - $pointeurs = []; |
|
| 221 | - while ((is_countable($c) ? count($c) : 0) && ($cc = array_shift($c))) { |
|
| 222 | - // creer l'entree si elle n'existe pas |
|
| 223 | - if (!isset($sc[$cc])) { |
|
| 224 | - // si on essaye d'effacer une config qui n'existe pas |
|
| 225 | - // ne rien creer mais sortir |
|
| 226 | - if (is_null($store)) { |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - $sc[$cc] = []; |
|
| 230 | - } |
|
| 231 | - $pointeurs[$cc] = &$sc; |
|
| 232 | - $sc = &$sc[$cc]; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - // si c'est une demande d'effacement |
|
| 236 | - if (is_null($store)) { |
|
| 237 | - $c = $sous_casier; |
|
| 238 | - $sous = array_pop($c); |
|
| 239 | - // effacer, et remonter pour effacer les parents vides |
|
| 240 | - do { |
|
| 241 | - unset($pointeurs[$sous][$sous]); |
|
| 242 | - } while (($sous = array_pop($c)) && !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 243 | - |
|
| 244 | - // si on a vide tous les sous casiers, |
|
| 245 | - // et que le casier est vide |
|
| 246 | - // vider aussi la meta |
|
| 247 | - if (!$sous && !(is_countable($st) ? count($st) : 0)) { |
|
| 248 | - $st = null; |
|
| 249 | - } |
|
| 250 | - } // dans tous les autres cas, on ecrase |
|
| 251 | - else { |
|
| 252 | - if ( |
|
| 253 | - defined('_MYSQL_NOPLANES') |
|
| 254 | - && _MYSQL_NOPLANES |
|
| 255 | - && !empty($GLOBALS['meta']['charset_sql_connexion']) |
|
| 256 | - && $GLOBALS['meta']['charset_sql_connexion'] == 'utf8' |
|
| 257 | - ) { |
|
| 258 | - // detecter si la valeur qu'on veut ecrire a des planes |
|
| 259 | - // @see utf8_noplanes |
|
| 260 | - $serialized_store = (is_string($store) ? $store : serialize($store)); |
|
| 261 | - // un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes |
|
| 262 | - if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) { |
|
| 263 | - if (!function_exists('utf8_noplanes')) { |
|
| 264 | - include_spip('inc/charsets'); |
|
| 265 | - } |
|
| 266 | - if ($serialized_store !== utf8_noplanes($serialized_store)) { |
|
| 267 | - $has_planes = true; |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - $sc = $store; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - // Maintenant que $st est modifiee |
|
| 276 | - // reprenons la comme valeur a stocker dans le casier principal |
|
| 277 | - $store = $st; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - if (is_null($store)) { |
|
| 281 | - if (is_null($st) && !$sous_casier) { |
|
| 282 | - return false; |
|
| 283 | - } // la config n'existait deja pas ! |
|
| 284 | - effacer_meta($casier, $table); |
|
| 285 | - supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 286 | - } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 287 | - else { |
|
| 288 | - if (!isset($GLOBALS[$table])) { |
|
| 289 | - installer_table_meta($table); |
|
| 290 | - } |
|
| 291 | - // si ce n'est pas une chaine |
|
| 292 | - // il faut serializer |
|
| 293 | - if (!is_string($store)) { |
|
| 294 | - $serialized_store = serialize($store); |
|
| 295 | - ecrire_meta($casier, $serialized_store, null, $table); |
|
| 296 | - // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine |
|
| 297 | - // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4) |
|
| 298 | - if ($has_planes) { |
|
| 299 | - $check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier)); |
|
| 300 | - if ($check_store !== $serialized_store) { |
|
| 301 | - array_walk_recursive($store, function (&$value, $key) { |
|
| 302 | - if (is_string($value)) { |
|
| 303 | - $value = utf8_noplanes($value); |
|
| 304 | - } |
|
| 305 | - }); |
|
| 306 | - $serialized_store = serialize($store); |
|
| 307 | - ecrire_meta($casier, $serialized_store, null, $table); |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - else { |
|
| 312 | - ecrire_meta($casier, $store, null, $table); |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - // verifier que lire_config($cfg)==$store ? |
|
| 317 | - return true; |
|
| 180 | + // Brancher sur methodes externes si besoin |
|
| 181 | + if ($cfg && ($p = strpos($cfg, '::'))) { |
|
| 182 | + $methode = substr($cfg, 0, $p); |
|
| 183 | + $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 184 | + |
|
| 185 | + return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 189 | + // il faut au moins un casier pour ecrire |
|
| 190 | + if (!$casier) { |
|
| 191 | + return false; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + // trouvons ou creons le pointeur sur le casier |
|
| 195 | + $st = $GLOBALS[$table][$casier] ?? null; |
|
| 196 | + if (!is_array($st) && ($sous_casier || is_array($store))) { |
|
| 197 | + if ($st === null) { |
|
| 198 | + // ne rien creer si c'est une demande d'effacement |
|
| 199 | + if ($store === null) { |
|
| 200 | + return false; |
|
| 201 | + } |
|
| 202 | + $st = []; |
|
| 203 | + } else { |
|
| 204 | + $st = unserialize($st); |
|
| 205 | + if ($st === false) { |
|
| 206 | + // ne rien creer si c'est une demande d'effacement |
|
| 207 | + if ($store === null) { |
|
| 208 | + return false; |
|
| 209 | + } |
|
| 210 | + $st = []; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $has_planes = false; |
|
| 216 | + // si on a affaire a un sous caiser |
|
| 217 | + // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 218 | + if ($c = $sous_casier) { |
|
| 219 | + $sc = &$st; |
|
| 220 | + $pointeurs = []; |
|
| 221 | + while ((is_countable($c) ? count($c) : 0) && ($cc = array_shift($c))) { |
|
| 222 | + // creer l'entree si elle n'existe pas |
|
| 223 | + if (!isset($sc[$cc])) { |
|
| 224 | + // si on essaye d'effacer une config qui n'existe pas |
|
| 225 | + // ne rien creer mais sortir |
|
| 226 | + if (is_null($store)) { |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + $sc[$cc] = []; |
|
| 230 | + } |
|
| 231 | + $pointeurs[$cc] = &$sc; |
|
| 232 | + $sc = &$sc[$cc]; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + // si c'est une demande d'effacement |
|
| 236 | + if (is_null($store)) { |
|
| 237 | + $c = $sous_casier; |
|
| 238 | + $sous = array_pop($c); |
|
| 239 | + // effacer, et remonter pour effacer les parents vides |
|
| 240 | + do { |
|
| 241 | + unset($pointeurs[$sous][$sous]); |
|
| 242 | + } while (($sous = array_pop($c)) && !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 243 | + |
|
| 244 | + // si on a vide tous les sous casiers, |
|
| 245 | + // et que le casier est vide |
|
| 246 | + // vider aussi la meta |
|
| 247 | + if (!$sous && !(is_countable($st) ? count($st) : 0)) { |
|
| 248 | + $st = null; |
|
| 249 | + } |
|
| 250 | + } // dans tous les autres cas, on ecrase |
|
| 251 | + else { |
|
| 252 | + if ( |
|
| 253 | + defined('_MYSQL_NOPLANES') |
|
| 254 | + && _MYSQL_NOPLANES |
|
| 255 | + && !empty($GLOBALS['meta']['charset_sql_connexion']) |
|
| 256 | + && $GLOBALS['meta']['charset_sql_connexion'] == 'utf8' |
|
| 257 | + ) { |
|
| 258 | + // detecter si la valeur qu'on veut ecrire a des planes |
|
| 259 | + // @see utf8_noplanes |
|
| 260 | + $serialized_store = (is_string($store) ? $store : serialize($store)); |
|
| 261 | + // un preg_match rapide pour voir si ca vaut le coup de lancer utf8_noplanes |
|
| 262 | + if (preg_match(',[\xF0-\xF4],ms', $serialized_store)) { |
|
| 263 | + if (!function_exists('utf8_noplanes')) { |
|
| 264 | + include_spip('inc/charsets'); |
|
| 265 | + } |
|
| 266 | + if ($serialized_store !== utf8_noplanes($serialized_store)) { |
|
| 267 | + $has_planes = true; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + $sc = $store; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + // Maintenant que $st est modifiee |
|
| 276 | + // reprenons la comme valeur a stocker dans le casier principal |
|
| 277 | + $store = $st; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + if (is_null($store)) { |
|
| 281 | + if (is_null($st) && !$sous_casier) { |
|
| 282 | + return false; |
|
| 283 | + } // la config n'existait deja pas ! |
|
| 284 | + effacer_meta($casier, $table); |
|
| 285 | + supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 286 | + } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 287 | + else { |
|
| 288 | + if (!isset($GLOBALS[$table])) { |
|
| 289 | + installer_table_meta($table); |
|
| 290 | + } |
|
| 291 | + // si ce n'est pas une chaine |
|
| 292 | + // il faut serializer |
|
| 293 | + if (!is_string($store)) { |
|
| 294 | + $serialized_store = serialize($store); |
|
| 295 | + ecrire_meta($casier, $serialized_store, null, $table); |
|
| 296 | + // et dans ce cas il faut verifier que l'ecriture en base a bien eu lieu a l'identique si il y a des planes dans la chaine |
|
| 297 | + // car sinon ca casse le serialize PHP - par exemple si on est en mysql utf8 (non mb4) |
|
| 298 | + if ($has_planes) { |
|
| 299 | + $check_store = sql_getfetsel('valeur', 'spip_' . $table, 'nom=' . sql_quote($casier)); |
|
| 300 | + if ($check_store !== $serialized_store) { |
|
| 301 | + array_walk_recursive($store, function (&$value, $key) { |
|
| 302 | + if (is_string($value)) { |
|
| 303 | + $value = utf8_noplanes($value); |
|
| 304 | + } |
|
| 305 | + }); |
|
| 306 | + $serialized_store = serialize($store); |
|
| 307 | + ecrire_meta($casier, $serialized_store, null, $table); |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + else { |
|
| 312 | + ecrire_meta($casier, $store, null, $table); |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + // verifier que lire_config($cfg)==$store ? |
|
| 317 | + return true; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | |
@@ -327,14 +327,14 @@ discard block |
||
| 327 | 327 | * @return bool |
| 328 | 328 | */ |
| 329 | 329 | function ecrire_config_metapack_dist($cfg, mixed $store) { |
| 330 | - // cas particulier en metapack:: |
|
| 331 | - // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 332 | - // intacte en sortie ... |
|
| 333 | - if (is_string($store) && strpos($store, ':') && unserialize($store)) { |
|
| 334 | - $store = serialize($store); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return ecrire_config($cfg, $store); |
|
| 330 | + // cas particulier en metapack:: |
|
| 331 | + // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 332 | + // intacte en sortie ... |
|
| 333 | + if (is_string($store) && strpos($store, ':') && unserialize($store)) { |
|
| 334 | + $store = serialize($store); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return ecrire_config($cfg, $store); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | /** |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | * @return bool |
| 345 | 345 | */ |
| 346 | 346 | function effacer_config($cfg) { |
| 347 | - ecrire_config($cfg, null); |
|
| 347 | + ecrire_config($cfg, null); |
|
| 348 | 348 | |
| 349 | - return true; |
|
| 349 | + return true; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -363,58 +363,58 @@ discard block |
||
| 363 | 363 | * Couples nom de la `meta` => valeur par défaut |
| 364 | 364 | */ |
| 365 | 365 | function liste_metas() { |
| 366 | - return pipeline('configurer_liste_metas', [ |
|
| 367 | - 'nom_site' => _T('info_mon_site_spip'), |
|
| 368 | - 'slogan_site' => '', |
|
| 369 | - 'adresse_site' => preg_replace(',/$,', '', (string) url_de_base()), |
|
| 370 | - 'descriptif_site' => '', |
|
| 371 | - 'activer_logos' => 'oui', |
|
| 372 | - 'activer_logos_survol' => 'non', |
|
| 373 | - 'articles_surtitre' => 'non', |
|
| 374 | - 'articles_soustitre' => 'non', |
|
| 375 | - 'articles_descriptif' => 'non', |
|
| 376 | - 'articles_chapeau' => 'non', |
|
| 377 | - 'articles_texte' => 'oui', |
|
| 378 | - 'articles_ps' => 'non', |
|
| 379 | - 'articles_redac' => 'non', |
|
| 380 | - 'post_dates' => 'non', |
|
| 381 | - 'articles_urlref' => 'non', |
|
| 382 | - 'articles_redirection' => 'non', |
|
| 383 | - 'creer_preview' => 'non', |
|
| 384 | - 'taille_preview' => 150, |
|
| 385 | - 'articles_modif' => 'non', |
|
| 386 | - |
|
| 387 | - 'rubriques_descriptif' => 'non', |
|
| 388 | - 'rubriques_texte' => 'oui', |
|
| 389 | - |
|
| 390 | - 'accepter_inscriptions' => 'non', |
|
| 391 | - 'accepter_visiteurs' => 'non', |
|
| 392 | - 'prevenir_auteurs' => 'non', |
|
| 393 | - 'suivi_edito' => 'non', |
|
| 394 | - 'adresse_suivi' => '', |
|
| 395 | - 'adresse_suivi_inscription' => '', |
|
| 396 | - 'adresse_neuf' => '', |
|
| 397 | - 'jours_neuf' => '', |
|
| 398 | - 'quoi_de_neuf' => 'non', |
|
| 399 | - 'preview' => ',0minirezo,1comite,', |
|
| 400 | - |
|
| 401 | - 'syndication_integrale' => 'oui', |
|
| 402 | - 'charset' => _DEFAULT_CHARSET, |
|
| 403 | - 'dir_img' => substr((string) _DIR_IMG, strlen(_DIR_RACINE)), |
|
| 404 | - |
|
| 405 | - 'multi_rubriques' => 'non', |
|
| 406 | - 'multi_secteurs' => 'non', |
|
| 407 | - 'gerer_trad' => 'non', |
|
| 408 | - 'langues_multilingue' => '', |
|
| 409 | - |
|
| 410 | - 'version_html_max' => 'html4', |
|
| 411 | - |
|
| 412 | - 'type_urls' => 'page', |
|
| 413 | - |
|
| 414 | - 'email_envoi' => '', |
|
| 415 | - 'email_webmaster' => '', |
|
| 416 | - 'auto_compress_http' => 'non', |
|
| 417 | - ]); |
|
| 366 | + return pipeline('configurer_liste_metas', [ |
|
| 367 | + 'nom_site' => _T('info_mon_site_spip'), |
|
| 368 | + 'slogan_site' => '', |
|
| 369 | + 'adresse_site' => preg_replace(',/$,', '', (string) url_de_base()), |
|
| 370 | + 'descriptif_site' => '', |
|
| 371 | + 'activer_logos' => 'oui', |
|
| 372 | + 'activer_logos_survol' => 'non', |
|
| 373 | + 'articles_surtitre' => 'non', |
|
| 374 | + 'articles_soustitre' => 'non', |
|
| 375 | + 'articles_descriptif' => 'non', |
|
| 376 | + 'articles_chapeau' => 'non', |
|
| 377 | + 'articles_texte' => 'oui', |
|
| 378 | + 'articles_ps' => 'non', |
|
| 379 | + 'articles_redac' => 'non', |
|
| 380 | + 'post_dates' => 'non', |
|
| 381 | + 'articles_urlref' => 'non', |
|
| 382 | + 'articles_redirection' => 'non', |
|
| 383 | + 'creer_preview' => 'non', |
|
| 384 | + 'taille_preview' => 150, |
|
| 385 | + 'articles_modif' => 'non', |
|
| 386 | + |
|
| 387 | + 'rubriques_descriptif' => 'non', |
|
| 388 | + 'rubriques_texte' => 'oui', |
|
| 389 | + |
|
| 390 | + 'accepter_inscriptions' => 'non', |
|
| 391 | + 'accepter_visiteurs' => 'non', |
|
| 392 | + 'prevenir_auteurs' => 'non', |
|
| 393 | + 'suivi_edito' => 'non', |
|
| 394 | + 'adresse_suivi' => '', |
|
| 395 | + 'adresse_suivi_inscription' => '', |
|
| 396 | + 'adresse_neuf' => '', |
|
| 397 | + 'jours_neuf' => '', |
|
| 398 | + 'quoi_de_neuf' => 'non', |
|
| 399 | + 'preview' => ',0minirezo,1comite,', |
|
| 400 | + |
|
| 401 | + 'syndication_integrale' => 'oui', |
|
| 402 | + 'charset' => _DEFAULT_CHARSET, |
|
| 403 | + 'dir_img' => substr((string) _DIR_IMG, strlen(_DIR_RACINE)), |
|
| 404 | + |
|
| 405 | + 'multi_rubriques' => 'non', |
|
| 406 | + 'multi_secteurs' => 'non', |
|
| 407 | + 'gerer_trad' => 'non', |
|
| 408 | + 'langues_multilingue' => '', |
|
| 409 | + |
|
| 410 | + 'version_html_max' => 'html4', |
|
| 411 | + |
|
| 412 | + 'type_urls' => 'page', |
|
| 413 | + |
|
| 414 | + 'email_envoi' => '', |
|
| 415 | + 'email_webmaster' => '', |
|
| 416 | + 'auto_compress_http' => 'non', |
|
| 417 | + ]); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -425,43 +425,43 @@ discard block |
||
| 425 | 425 | * @return void |
| 426 | 426 | */ |
| 427 | 427 | function actualise_metas($liste_meta) { |
| 428 | - $meta_serveur = |
|
| 429 | - [ |
|
| 430 | - 'version_installee', |
|
| 431 | - 'adresse_site', |
|
| 432 | - 'alea_ephemere_ancien', |
|
| 433 | - 'alea_ephemere', |
|
| 434 | - 'alea_ephemere_date', |
|
| 435 | - 'langue_site', |
|
| 436 | - 'langues_proposees', |
|
| 437 | - 'date_calcul_rubriques', |
|
| 438 | - 'derniere_modif', |
|
| 439 | - 'optimiser_table', |
|
| 440 | - 'drapeau_edition', |
|
| 441 | - 'creer_preview', |
|
| 442 | - 'taille_preview', |
|
| 443 | - 'creer_htpasswd', |
|
| 444 | - 'creer_htaccess', |
|
| 445 | - 'gd_formats_read', |
|
| 446 | - 'gd_formats', |
|
| 447 | - 'netpbm_formats', |
|
| 448 | - 'formats_graphiques', |
|
| 449 | - 'image_process', |
|
| 450 | - 'plugin_header', |
|
| 451 | - 'plugin' |
|
| 452 | - ]; |
|
| 453 | - // verifier le impt=non |
|
| 454 | - sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 455 | - |
|
| 456 | - foreach ($liste_meta as $nom => $valeur) { |
|
| 457 | - if (empty($GLOBALS['meta'][$nom])) { |
|
| 458 | - ecrire_meta($nom, $valeur); |
|
| 459 | - } |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - include_spip('inc/rubriques'); |
|
| 463 | - $langues = calculer_langues_utilisees(); |
|
| 464 | - ecrire_meta('langues_utilisees', $langues); |
|
| 428 | + $meta_serveur = |
|
| 429 | + [ |
|
| 430 | + 'version_installee', |
|
| 431 | + 'adresse_site', |
|
| 432 | + 'alea_ephemere_ancien', |
|
| 433 | + 'alea_ephemere', |
|
| 434 | + 'alea_ephemere_date', |
|
| 435 | + 'langue_site', |
|
| 436 | + 'langues_proposees', |
|
| 437 | + 'date_calcul_rubriques', |
|
| 438 | + 'derniere_modif', |
|
| 439 | + 'optimiser_table', |
|
| 440 | + 'drapeau_edition', |
|
| 441 | + 'creer_preview', |
|
| 442 | + 'taille_preview', |
|
| 443 | + 'creer_htpasswd', |
|
| 444 | + 'creer_htaccess', |
|
| 445 | + 'gd_formats_read', |
|
| 446 | + 'gd_formats', |
|
| 447 | + 'netpbm_formats', |
|
| 448 | + 'formats_graphiques', |
|
| 449 | + 'image_process', |
|
| 450 | + 'plugin_header', |
|
| 451 | + 'plugin' |
|
| 452 | + ]; |
|
| 453 | + // verifier le impt=non |
|
| 454 | + sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 455 | + |
|
| 456 | + foreach ($liste_meta as $nom => $valeur) { |
|
| 457 | + if (empty($GLOBALS['meta'][$nom])) { |
|
| 458 | + ecrire_meta($nom, $valeur); |
|
| 459 | + } |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + include_spip('inc/rubriques'); |
|
| 463 | + $langues = calculer_langues_utilisees(); |
|
| 464 | + ecrire_meta('langues_utilisees', $langues); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | |
@@ -483,18 +483,18 @@ discard block |
||
| 483 | 483 | */ |
| 484 | 484 | function appliquer_modifs_config($purger_skel = false) { |
| 485 | 485 | |
| 486 | - foreach (liste_metas() as $i => $v) { |
|
| 487 | - if (($x = _request($i)) !== null) { |
|
| 488 | - ecrire_meta($i, $x); |
|
| 489 | - } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 490 | - ecrire_meta($i, $v); |
|
| 491 | - } |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - if ($purger_skel) { |
|
| 495 | - include_spip('inc/invalideur'); |
|
| 496 | - purger_repertoire(_DIR_SKELS); |
|
| 497 | - } |
|
| 486 | + foreach (liste_metas() as $i => $v) { |
|
| 487 | + if (($x = _request($i)) !== null) { |
|
| 488 | + ecrire_meta($i, $x); |
|
| 489 | + } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 490 | + ecrire_meta($i, $v); |
|
| 491 | + } |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + if ($purger_skel) { |
|
| 495 | + include_spip('inc/invalideur'); |
|
| 496 | + purger_repertoire(_DIR_SKELS); |
|
| 497 | + } |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -505,21 +505,21 @@ discard block |
||
| 505 | 505 | * @return string |
| 506 | 506 | */ |
| 507 | 507 | function appliquer_adresse_site($adresse_site) { |
| 508 | - if ($adresse_site !== null) { |
|
| 509 | - if (!strlen($adresse_site)) { |
|
| 510 | - $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 511 | - $adresse_site = url_de_base(); |
|
| 512 | - } |
|
| 513 | - $adresse_site = preg_replace(',/?\s*$,', '', (string) $adresse_site); |
|
| 508 | + if ($adresse_site !== null) { |
|
| 509 | + if (!strlen($adresse_site)) { |
|
| 510 | + $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 511 | + $adresse_site = url_de_base(); |
|
| 512 | + } |
|
| 513 | + $adresse_site = preg_replace(',/?\s*$,', '', (string) $adresse_site); |
|
| 514 | 514 | |
| 515 | - if (!tester_url_absolue($adresse_site)) { |
|
| 516 | - $adresse_site = "http://$adresse_site"; |
|
| 517 | - } |
|
| 515 | + if (!tester_url_absolue($adresse_site)) { |
|
| 516 | + $adresse_site = "http://$adresse_site"; |
|
| 517 | + } |
|
| 518 | 518 | |
| 519 | - $adresse_site = entites_html($adresse_site); |
|
| 519 | + $adresse_site = entites_html($adresse_site); |
|
| 520 | 520 | |
| 521 | - ecrire_meta('adresse_site', $adresse_site); |
|
| 522 | - } |
|
| 521 | + ecrire_meta('adresse_site', $adresse_site); |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | - return $adresse_site; |
|
| 524 | + return $adresse_site; |
|
| 525 | 525 | } |