@@ -1,94 +1,94 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | function formulaires_configurer_ecran_connexion_data(): array { |
| 4 | - return [ |
|
| 5 | - 'couleur_defaut' => '#db1762', |
|
| 6 | - 'img_fond' => _DIR_IMG . 'spip_fond_login.jpg', |
|
| 7 | - ]; |
|
| 4 | + return [ |
|
| 5 | + 'couleur_defaut' => '#db1762', |
|
| 6 | + 'img_fond' => _DIR_IMG . 'spip_fond_login.jpg', |
|
| 7 | + ]; |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | function formulaires_configurer_ecran_connexion_charger_dist() { |
| 11 | - include_spip('inc/config'); |
|
| 12 | - include_spip('inc/autoriser'); |
|
| 11 | + include_spip('inc/config'); |
|
| 12 | + include_spip('inc/autoriser'); |
|
| 13 | 13 | |
| 14 | - $data = formulaires_configurer_ecran_connexion_data(); |
|
| 14 | + $data = formulaires_configurer_ecran_connexion_data(); |
|
| 15 | 15 | |
| 16 | - $valeurs = [ |
|
| 17 | - 'couleur_login' => lire_config('couleur_login', $data['couleur_defaut']), |
|
| 18 | - 'couleur_defaut_login' => $data['couleur_defaut'], |
|
| 19 | - 'upload_image_fond_login' => '', |
|
| 20 | - ]; |
|
| 16 | + $valeurs = [ |
|
| 17 | + 'couleur_login' => lire_config('couleur_login', $data['couleur_defaut']), |
|
| 18 | + 'couleur_defaut_login' => $data['couleur_defaut'], |
|
| 19 | + 'upload_image_fond_login' => '', |
|
| 20 | + ]; |
|
| 21 | 21 | |
| 22 | - if (file_exists($data['img_fond'])) { |
|
| 23 | - $valeurs['src_img'] = $data['img_fond']; |
|
| 24 | - } |
|
| 22 | + if (file_exists($data['img_fond'])) { |
|
| 23 | + $valeurs['src_img'] = $data['img_fond']; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - return $valeurs; |
|
| 26 | + return $valeurs; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | function formulaires_configurer_ecran_connexion_verifier_dist() { |
| 31 | - $erreurs = []; |
|
| 32 | - |
|
| 33 | - if (_request('supprimer_image_fond_login')) { |
|
| 34 | - // rien à tester |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - elseif (_request('supprimer_couleur_login')) { |
|
| 38 | - // rien à tester |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - elseif (!empty($_FILES['upload_image_fond_login'])) { |
|
| 42 | - $file = $_FILES['upload_image_fond_login']; |
|
| 43 | - include_spip('inc/documents'); |
|
| 44 | - $extension = pathinfo((string) $file['name'], PATHINFO_EXTENSION); |
|
| 45 | - $extension = corriger_extension(strtolower($extension)); |
|
| 46 | - if ($extension != 'jpg') { |
|
| 47 | - $erreurs['upload_image_fond_login'] = _T('erreur_type_fichier'); |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - return $erreurs; |
|
| 31 | + $erreurs = []; |
|
| 32 | + |
|
| 33 | + if (_request('supprimer_image_fond_login')) { |
|
| 34 | + // rien à tester |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + elseif (_request('supprimer_couleur_login')) { |
|
| 38 | + // rien à tester |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + elseif (!empty($_FILES['upload_image_fond_login'])) { |
|
| 42 | + $file = $_FILES['upload_image_fond_login']; |
|
| 43 | + include_spip('inc/documents'); |
|
| 44 | + $extension = pathinfo((string) $file['name'], PATHINFO_EXTENSION); |
|
| 45 | + $extension = corriger_extension(strtolower($extension)); |
|
| 46 | + if ($extension != 'jpg') { |
|
| 47 | + $erreurs['upload_image_fond_login'] = _T('erreur_type_fichier'); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + return $erreurs; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | function formulaires_configurer_ecran_connexion_traiter_dist() { |
| 56 | 56 | |
| 57 | - $retours = [ |
|
| 58 | - 'message_ok' => _T('config_info_enregistree'), |
|
| 59 | - 'editable' => true, |
|
| 60 | - ]; |
|
| 61 | - |
|
| 62 | - include_spip('inc/config'); |
|
| 63 | - $data = formulaires_configurer_ecran_connexion_data(); |
|
| 64 | - $dest = $data['img_fond']; |
|
| 65 | - |
|
| 66 | - if (_request('couleur_login')) { |
|
| 67 | - $color = _request('couleur_login'); |
|
| 68 | - if ($color === $data['couleur_defaut']) { |
|
| 69 | - effacer_config('couleur_login'); |
|
| 70 | - } else { |
|
| 71 | - ecrire_config('couleur_login', $color); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - if (_request('supprimer_image_fond_login')) { |
|
| 76 | - @unlink($dest); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - elseif (_request('supprimer_couleur_login')) { |
|
| 80 | - effacer_config('couleur_login'); |
|
| 81 | - set_request('couleur_login', null); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - elseif (!empty($_FILES['upload_image_fond_login'])) { |
|
| 85 | - $file = $_FILES['upload_image_fond_login']; |
|
| 86 | - include_spip('inc/documents'); |
|
| 87 | - deplacer_fichier_upload($file['tmp_name'], $dest); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - include_spip('inc/invalideur'); |
|
| 91 | - suivre_invalideur('1'); # tout effacer |
|
| 92 | - |
|
| 93 | - return $retours; |
|
| 57 | + $retours = [ |
|
| 58 | + 'message_ok' => _T('config_info_enregistree'), |
|
| 59 | + 'editable' => true, |
|
| 60 | + ]; |
|
| 61 | + |
|
| 62 | + include_spip('inc/config'); |
|
| 63 | + $data = formulaires_configurer_ecran_connexion_data(); |
|
| 64 | + $dest = $data['img_fond']; |
|
| 65 | + |
|
| 66 | + if (_request('couleur_login')) { |
|
| 67 | + $color = _request('couleur_login'); |
|
| 68 | + if ($color === $data['couleur_defaut']) { |
|
| 69 | + effacer_config('couleur_login'); |
|
| 70 | + } else { |
|
| 71 | + ecrire_config('couleur_login', $color); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + if (_request('supprimer_image_fond_login')) { |
|
| 76 | + @unlink($dest); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + elseif (_request('supprimer_couleur_login')) { |
|
| 80 | + effacer_config('couleur_login'); |
|
| 81 | + set_request('couleur_login', null); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + elseif (!empty($_FILES['upload_image_fond_login'])) { |
|
| 85 | + $file = $_FILES['upload_image_fond_login']; |
|
| 86 | + include_spip('inc/documents'); |
|
| 87 | + deplacer_fichier_upload($file['tmp_name'], $dest); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + include_spip('inc/invalideur'); |
|
| 91 | + suivre_invalideur('1'); # tout effacer |
|
| 92 | + |
|
| 93 | + return $retours; |
|
| 94 | 94 | } |
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 4 | - return; |
|
| 4 | + return; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function trier_rss($texte) { |
| 8 | - if (preg_match_all(',<item.*</item>\s*?,Uims', (string) $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | - $placeholder = '<!--REINSERT-->'; |
|
| 10 | - $items = []; |
|
| 11 | - foreach ($matches as $match) { |
|
| 12 | - if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | - $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | - $texte = str_replace($match[0], unique($placeholder), (string) $texte); |
|
| 15 | - } |
|
| 16 | - } |
|
| 17 | - krsort($items); |
|
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", (string) $texte); |
|
| 19 | - } |
|
| 8 | + if (preg_match_all(',<item.*</item>\s*?,Uims', (string) $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | + $placeholder = '<!--REINSERT-->'; |
|
| 10 | + $items = []; |
|
| 11 | + foreach ($matches as $match) { |
|
| 12 | + if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | + $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | + $texte = str_replace($match[0], unique($placeholder), (string) $texte); |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | + krsort($items); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", (string) $texte); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return $texte; |
|
| 21 | + return $texte; |
|
| 22 | 22 | } |
@@ -10,40 +10,40 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | function defaut_tri_defined($defaut) { |
| 17 | - if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 18 | - return $defaut; |
|
| 19 | - } |
|
| 17 | + if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 18 | + return $defaut; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - $sens = 1; |
|
| 22 | - $tri = trim((string) _TRI_ARTICLES_RUBRIQUE); |
|
| 23 | - $tri = explode(' ', $tri); |
|
| 24 | - if (strncasecmp(end($tri), 'DESC', 4) == 0) { |
|
| 25 | - $sens = -1; |
|
| 26 | - array_pop($tri); |
|
| 27 | - } elseif (strncasecmp(end($tri), 'ASC', 3) == 0) { |
|
| 28 | - $sens = 1; |
|
| 29 | - array_pop($tri); |
|
| 30 | - } |
|
| 31 | - $tri = implode(' ', $tri); |
|
| 32 | - $tri = [$tri => $sens]; |
|
| 33 | - foreach ($defaut as $n => $s) { |
|
| 34 | - if (!isset($tri[$n])) { |
|
| 35 | - $tri[$n] = $s; |
|
| 36 | - } |
|
| 37 | - } |
|
| 21 | + $sens = 1; |
|
| 22 | + $tri = trim((string) _TRI_ARTICLES_RUBRIQUE); |
|
| 23 | + $tri = explode(' ', $tri); |
|
| 24 | + if (strncasecmp(end($tri), 'DESC', 4) == 0) { |
|
| 25 | + $sens = -1; |
|
| 26 | + array_pop($tri); |
|
| 27 | + } elseif (strncasecmp(end($tri), 'ASC', 3) == 0) { |
|
| 28 | + $sens = 1; |
|
| 29 | + array_pop($tri); |
|
| 30 | + } |
|
| 31 | + $tri = implode(' ', $tri); |
|
| 32 | + $tri = [$tri => $sens]; |
|
| 33 | + foreach ($defaut as $n => $s) { |
|
| 34 | + if (!isset($tri[$n])) { |
|
| 35 | + $tri[$n] = $s; |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - return $tri; |
|
| 39 | + return $tri; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function defaut_tri_par($par, $defaut) { |
| 43 | - if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 44 | - return $par; |
|
| 45 | - } |
|
| 46 | - $par = array_keys($defaut); |
|
| 43 | + if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 44 | + return $par; |
|
| 45 | + } |
|
| 46 | + $par = array_keys($defaut); |
|
| 47 | 47 | |
| 48 | - return reset($par); |
|
| 48 | + return reset($par); |
|
| 49 | 49 | } |
@@ -10,53 +10,53 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // Fonction appelee par divers pipelines |
| 17 | 17 | function notifications_instituerarticle_dist($quoi, $id_article, $options) { |
| 18 | 18 | |
| 19 | - // ne devrait jamais se produire |
|
| 20 | - if ($options['statut'] == $options['statut_ancien']) { |
|
| 21 | - spip_log('statut inchange', 'notifications'); |
|
| 22 | - |
|
| 23 | - return; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - include_spip('inc/texte'); |
|
| 27 | - |
|
| 28 | - $modele = ''; |
|
| 29 | - if ($options['statut'] == 'publie') { |
|
| 30 | - if ( |
|
| 31 | - $GLOBALS['meta']['post_dates'] == 'non' |
|
| 32 | - && strtotime((string) $options['date']) > time() |
|
| 33 | - ) { |
|
| 34 | - $modele = 'notifications/article_valide'; |
|
| 35 | - } else { |
|
| 36 | - $modele = 'notifications/article_publie'; |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - if ($options['statut'] == 'prop' && $options['statut_ancien'] != 'publie') { |
|
| 41 | - $modele = 'notifications/article_propose'; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - if ($modele) { |
|
| 45 | - $destinataires = []; |
|
| 46 | - if ($GLOBALS['meta']['suivi_edito'] == 'oui') { |
|
| 47 | - $destinataires = explode(',', (string) $GLOBALS['meta']['adresse_suivi']); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - $destinataires = pipeline( |
|
| 52 | - 'notifications_destinataires', |
|
| 53 | - [ |
|
| 54 | - 'args' => ['quoi' => $quoi, 'id' => $id_article, 'options' => $options], |
|
| 55 | - 'data' => $destinataires |
|
| 56 | - ] |
|
| 57 | - ); |
|
| 58 | - |
|
| 59 | - $texte = email_notification_article($id_article, $modele); |
|
| 60 | - notifications_envoyer_mails($destinataires, $texte); |
|
| 61 | - } |
|
| 19 | + // ne devrait jamais se produire |
|
| 20 | + if ($options['statut'] == $options['statut_ancien']) { |
|
| 21 | + spip_log('statut inchange', 'notifications'); |
|
| 22 | + |
|
| 23 | + return; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + include_spip('inc/texte'); |
|
| 27 | + |
|
| 28 | + $modele = ''; |
|
| 29 | + if ($options['statut'] == 'publie') { |
|
| 30 | + if ( |
|
| 31 | + $GLOBALS['meta']['post_dates'] == 'non' |
|
| 32 | + && strtotime((string) $options['date']) > time() |
|
| 33 | + ) { |
|
| 34 | + $modele = 'notifications/article_valide'; |
|
| 35 | + } else { |
|
| 36 | + $modele = 'notifications/article_publie'; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + if ($options['statut'] == 'prop' && $options['statut_ancien'] != 'publie') { |
|
| 41 | + $modele = 'notifications/article_propose'; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + if ($modele) { |
|
| 45 | + $destinataires = []; |
|
| 46 | + if ($GLOBALS['meta']['suivi_edito'] == 'oui') { |
|
| 47 | + $destinataires = explode(',', (string) $GLOBALS['meta']['adresse_suivi']); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + $destinataires = pipeline( |
|
| 52 | + 'notifications_destinataires', |
|
| 53 | + [ |
|
| 54 | + 'args' => ['quoi' => $quoi, 'id' => $id_article, 'options' => $options], |
|
| 55 | + 'data' => $destinataires |
|
| 56 | + ] |
|
| 57 | + ); |
|
| 58 | + |
|
| 59 | + $texte = email_notification_article($id_article, $modele); |
|
| 60 | + notifications_envoyer_mails($destinataires, $texte); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | if (defined('_TEST_DIRS')) { |
| 17 | - return; |
|
| 17 | + return; |
|
| 18 | 18 | } |
| 19 | 19 | define('_TEST_DIRS', '1'); |
| 20 | 20 | |
@@ -26,38 +26,38 @@ discard block |
||
| 26 | 26 | // Tente d'ecrire |
| 27 | 27 | // |
| 28 | 28 | function test_ecrire($my_dir) { |
| 29 | - static $chmod = 0; |
|
| 30 | - |
|
| 31 | - $ok = false; |
|
| 32 | - $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 33 | - $self = basename((string) $script); |
|
| 34 | - $uid = @fileowner('.'); |
|
| 35 | - $uid2 = @fileowner($self); |
|
| 36 | - $gid = @filegroup('.'); |
|
| 37 | - $gid2 = @filegroup($self); |
|
| 38 | - $perms = @fileperms($self); |
|
| 39 | - |
|
| 40 | - // Comparer l'appartenance d'un fichier cree par PHP |
|
| 41 | - // avec celle du script et du repertoire courant |
|
| 42 | - if (!$chmod) { |
|
| 43 | - @rmdir('test'); |
|
| 44 | - spip_unlink('test'); // effacer au cas ou |
|
| 45 | - @touch('test'); |
|
| 46 | - if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 47 | - $chmod = 0700; |
|
| 48 | - } else { |
|
| 49 | - $chmod = $gid > 0 && $gid == $gid2 && @filegroup('test') == $gid ? 0770 : 0777; |
|
| 50 | - } |
|
| 51 | - // Appliquer de plus les droits d'acces du script |
|
| 52 | - if ($perms > 0) { |
|
| 53 | - $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 54 | - $chmod |= $perms; |
|
| 55 | - } |
|
| 56 | - spip_unlink('test'); |
|
| 57 | - } |
|
| 58 | - $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 59 | - |
|
| 60 | - return $ok ? $chmod : false; |
|
| 29 | + static $chmod = 0; |
|
| 30 | + |
|
| 31 | + $ok = false; |
|
| 32 | + $script = @file_exists('spip_loader.php') ? 'spip_loader.php' : $_SERVER['PHP_SELF']; |
|
| 33 | + $self = basename((string) $script); |
|
| 34 | + $uid = @fileowner('.'); |
|
| 35 | + $uid2 = @fileowner($self); |
|
| 36 | + $gid = @filegroup('.'); |
|
| 37 | + $gid2 = @filegroup($self); |
|
| 38 | + $perms = @fileperms($self); |
|
| 39 | + |
|
| 40 | + // Comparer l'appartenance d'un fichier cree par PHP |
|
| 41 | + // avec celle du script et du repertoire courant |
|
| 42 | + if (!$chmod) { |
|
| 43 | + @rmdir('test'); |
|
| 44 | + spip_unlink('test'); // effacer au cas ou |
|
| 45 | + @touch('test'); |
|
| 46 | + if ($uid > 0 && $uid == $uid2 && @fileowner('test') == $uid) { |
|
| 47 | + $chmod = 0700; |
|
| 48 | + } else { |
|
| 49 | + $chmod = $gid > 0 && $gid == $gid2 && @filegroup('test') == $gid ? 0770 : 0777; |
|
| 50 | + } |
|
| 51 | + // Appliquer de plus les droits d'acces du script |
|
| 52 | + if ($perms > 0) { |
|
| 53 | + $perms = ($perms & 0777) | (($perms & 0444) >> 2); |
|
| 54 | + $chmod |= $perms; |
|
| 55 | + } |
|
| 56 | + spip_unlink('test'); |
|
| 57 | + } |
|
| 58 | + $ok = is_dir($my_dir) && is_writable($my_dir); |
|
| 59 | + |
|
| 60 | + return $ok ? $chmod : false; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // |
@@ -67,84 +67,84 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | function install_etape_chmod_dist() { |
| 69 | 69 | |
| 70 | - $continuer = null; |
|
| 71 | - $test_dir = _request('test_dir'); |
|
| 72 | - $chmod = 0; |
|
| 73 | - |
|
| 74 | - if ($test_dir && !str_contains((string) $test_dir, '..')) { |
|
| 75 | - if (!str_ends_with((string) $test_dir, '/')) { |
|
| 76 | - $test_dir .= '/'; |
|
| 77 | - } |
|
| 78 | - if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 79 | - $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 80 | - } |
|
| 81 | - } else { |
|
| 82 | - if (!_FILE_CONNECT) { |
|
| 83 | - $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 84 | - $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - $bad_dirs = []; |
|
| 89 | - $absent_dirs = []; |
|
| 90 | - |
|
| 91 | - foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 92 | - $test = test_ecrire($my_dir); |
|
| 93 | - if (!$test) { |
|
| 94 | - $m = preg_replace(',^' . _DIR_RACINE . ',', '', (string) $my_dir); |
|
| 95 | - if (@file_exists($my_dir)) { |
|
| 96 | - $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 97 | - } else { |
|
| 98 | - $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 99 | - } |
|
| 100 | - } else { |
|
| 101 | - $chmod = max($chmod, $test); |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if ($bad_dirs || $absent_dirs) { |
|
| 106 | - if (!_FILE_CONNECT) { |
|
| 107 | - $titre = _T('dirs_preliminaire'); |
|
| 108 | - $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 109 | - } else { |
|
| 110 | - $titre = _T('dirs_probleme_droits'); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 115 | - |
|
| 116 | - if ($bad_dirs) { |
|
| 117 | - $res .= |
|
| 118 | - _T( |
|
| 119 | - 'dirs_repertoires_suivants', |
|
| 120 | - ['bad_dirs' => implode("\n", array_keys($bad_dirs))] |
|
| 121 | - ) . |
|
| 122 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - if ($absent_dirs) { |
|
| 126 | - $res .= |
|
| 127 | - _T( |
|
| 128 | - 'dirs_repertoires_absents', |
|
| 129 | - ['bad_dirs' => implode("\n", array_keys($absent_dirs))] |
|
| 130 | - ) . |
|
| 131 | - '<b>' . _T('login_recharger') . '</b>.'; |
|
| 132 | - } |
|
| 133 | - $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 134 | - |
|
| 135 | - $t = _T('login_recharger'); |
|
| 136 | - $t = ($test_dir ? "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />" : |
|
| 137 | - '') |
|
| 138 | - . "<input type='hidden' name='etape' value='chmod' />" |
|
| 139 | - . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 140 | - |
|
| 141 | - echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 142 | - } else { |
|
| 143 | - $deja = (_FILE_CONNECT && analyse_fichier_connection(_FILE_CONNECT)); |
|
| 144 | - if (!$deja) { |
|
| 145 | - redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 146 | - } else { |
|
| 147 | - redirige_url_ecrire(); |
|
| 148 | - } |
|
| 149 | - } |
|
| 70 | + $continuer = null; |
|
| 71 | + $test_dir = _request('test_dir'); |
|
| 72 | + $chmod = 0; |
|
| 73 | + |
|
| 74 | + if ($test_dir && !str_contains((string) $test_dir, '..')) { |
|
| 75 | + if (!str_ends_with((string) $test_dir, '/')) { |
|
| 76 | + $test_dir .= '/'; |
|
| 77 | + } |
|
| 78 | + if (!in_array($test_dir, $GLOBALS['test_dirs'])) { |
|
| 79 | + $GLOBALS['test_dirs'][] = _DIR_RACINE . $test_dir; |
|
| 80 | + } |
|
| 81 | + } else { |
|
| 82 | + if (!_FILE_CONNECT) { |
|
| 83 | + $GLOBALS['test_dirs'][] = _DIR_CONNECT; |
|
| 84 | + $GLOBALS['test_dirs'][] = _DIR_CHMOD; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + $bad_dirs = []; |
|
| 89 | + $absent_dirs = []; |
|
| 90 | + |
|
| 91 | + foreach ($GLOBALS['test_dirs'] as $i => $my_dir) { |
|
| 92 | + $test = test_ecrire($my_dir); |
|
| 93 | + if (!$test) { |
|
| 94 | + $m = preg_replace(',^' . _DIR_RACINE . ',', '', (string) $my_dir); |
|
| 95 | + if (@file_exists($my_dir)) { |
|
| 96 | + $bad_dirs['<li>' . $m . '</li>'] = 1; |
|
| 97 | + } else { |
|
| 98 | + $absent_dirs['<li>' . $m . '</li>'] = 1; |
|
| 99 | + } |
|
| 100 | + } else { |
|
| 101 | + $chmod = max($chmod, $test); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if ($bad_dirs || $absent_dirs) { |
|
| 106 | + if (!_FILE_CONNECT) { |
|
| 107 | + $titre = _T('dirs_preliminaire'); |
|
| 108 | + $continuer = ' ' . _T('dirs_commencer') . '.'; |
|
| 109 | + } else { |
|
| 110 | + $titre = _T('dirs_probleme_droits'); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + $res = "<div align='right'>" . menu_langues('var_lang_ecrire') . "</div>\n"; |
|
| 115 | + |
|
| 116 | + if ($bad_dirs) { |
|
| 117 | + $res .= |
|
| 118 | + _T( |
|
| 119 | + 'dirs_repertoires_suivants', |
|
| 120 | + ['bad_dirs' => implode("\n", array_keys($bad_dirs))] |
|
| 121 | + ) . |
|
| 122 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + if ($absent_dirs) { |
|
| 126 | + $res .= |
|
| 127 | + _T( |
|
| 128 | + 'dirs_repertoires_absents', |
|
| 129 | + ['bad_dirs' => implode("\n", array_keys($absent_dirs))] |
|
| 130 | + ) . |
|
| 131 | + '<b>' . _T('login_recharger') . '</b>.'; |
|
| 132 | + } |
|
| 133 | + $res = '<p>' . $continuer . $res . aider('install0', true) . '</p>'; |
|
| 134 | + |
|
| 135 | + $t = _T('login_recharger'); |
|
| 136 | + $t = ($test_dir ? "<input type='hidden' name='test_dir' value='" . spip_htmlspecialchars($test_dir, ENT_QUOTES) . "' />" : |
|
| 137 | + '') |
|
| 138 | + . "<input type='hidden' name='etape' value='chmod' />" |
|
| 139 | + . "<div style='text-align: right'><input type='submit' value='" . attribut_html($t) . "' /></div>"; |
|
| 140 | + |
|
| 141 | + echo minipres($titre, $res . generer_form_ecrire('install', $t)); |
|
| 142 | + } else { |
|
| 143 | + $deja = (_FILE_CONNECT && analyse_fichier_connection(_FILE_CONNECT)); |
|
| 144 | + if (!$deja) { |
|
| 145 | + redirige_url_ecrire('install', 'etape=1&chmod=' . $chmod); |
|
| 146 | + } else { |
|
| 147 | + redirige_url_ecrire(); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | } |
@@ -10,167 +10,167 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/headers'); |
| 17 | 17 | |
| 18 | 18 | function install_etape_3b_dist() { |
| 19 | - $auth_spip = null; |
|
| 20 | - $session = null; |
|
| 21 | - $row = null; |
|
| 22 | - $login = _request('login'); |
|
| 23 | - $email = _request('email'); |
|
| 24 | - $nom = _request('nom'); |
|
| 25 | - $pass = _request('pass'); |
|
| 26 | - $pass_verif = _request('pass_verif'); |
|
| 27 | - |
|
| 28 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 29 | - ? _INSTALL_SERVER_DB |
|
| 30 | - : _request('server_db'); |
|
| 31 | - |
|
| 32 | - if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 33 | - define('_PASS_LONGUEUR_MINI', 6); |
|
| 34 | - } |
|
| 35 | - if (!defined('_LOGIN_TROP_COURT')) { |
|
| 36 | - define('_LOGIN_TROP_COURT', 4); |
|
| 37 | - } |
|
| 38 | - if ($login) { |
|
| 39 | - $echec = ($pass != $pass_verif) ? |
|
| 40 | - _T('info_passes_identiques') |
|
| 41 | - : ((strlen((string) $pass) < _PASS_LONGUEUR_MINI) ? |
|
| 42 | - _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 43 | - : ((strlen((string) $login) < _LOGIN_TROP_COURT) ? |
|
| 44 | - _T('info_login_trop_court') |
|
| 45 | - : '')); |
|
| 46 | - include_spip('inc/filtres'); |
|
| 47 | - if (!$echec && $email && !email_valide($email)) { |
|
| 48 | - $echec = _T('form_email_non_valide'); |
|
| 49 | - } |
|
| 50 | - if ($echec) { |
|
| 51 | - echouer_etape_3b($echec); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 56 | - include(_FILE_CHMOD_TMP); |
|
| 57 | - } else { |
|
| 58 | - redirige_url_ecrire('install'); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 62 | - redirige_url_ecrire('install'); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 66 | - # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 67 | - # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 68 | - |
|
| 69 | - lire_metas(); |
|
| 70 | - if ($login) { |
|
| 71 | - include_spip('inc/charsets'); |
|
| 72 | - |
|
| 73 | - $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 74 | - $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 75 | - $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 76 | - |
|
| 77 | - include_spip('auth/spip'); |
|
| 78 | - // prelablement, creer le champ webmestre si il n'existe pas (install neuve |
|
| 79 | - // sur une vieille base |
|
| 80 | - $t = sql_showtable('spip_auteurs', true); |
|
| 81 | - if (!isset($t['field']['webmestre'])) { |
|
| 82 | - @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - // il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre |
|
| 86 | - $cles = \Spip\Chiffrer\SpipCles::instance(); |
|
| 87 | - $secret = $cles->getSecretAuth(); |
|
| 88 | - |
|
| 89 | - $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 90 | - if ($id_auteur !== null) { |
|
| 91 | - // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
|
| 92 | - // pour restaurer la copie des cles |
|
| 93 | - if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 94 | - $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 95 | - if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
|
| 96 | - $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
|
| 97 | - echouer_etape_3b($echec); |
|
| 98 | - } |
|
| 99 | - spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 100 | - $cles->save(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - sql_updateq('spip_auteurs', [ |
|
| 104 | - 'nom' => $nom, |
|
| 105 | - 'email' => $email, |
|
| 106 | - 'login' => $login, |
|
| 107 | - 'statut' => '0minirezo' |
|
| 108 | - ], 'id_auteur=' . (int) $id_auteur); |
|
| 109 | - // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 110 | - @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 111 | - if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 112 | - $echec = _T('avis_erreur_creation_compte'); |
|
| 113 | - echouer_etape_3b($echec); |
|
| 114 | - } |
|
| 115 | - } else { |
|
| 116 | - // Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte : |
|
| 117 | - // il faut qu'un webmestre avec un backup fasse l'install |
|
| 118 | - if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 119 | - $echec = _T('avis_connexion_erreur_fichier_cle_manquant_2'); |
|
| 120 | - echouer_etape_3b($echec); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 124 | - 'nom' => $nom, |
|
| 125 | - 'email' => $email, |
|
| 126 | - 'login' => $login, |
|
| 127 | - 'statut' => '0minirezo' |
|
| 128 | - ]); |
|
| 129 | - // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 130 | - @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 131 | - if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 132 | - $echec = _T('avis_erreur_creation_compte'); |
|
| 133 | - echouer_etape_3b($echec); |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // inserer email comme email webmaster principal |
|
| 138 | - // (sauf s'il est vide: cas de la re-installation) |
|
| 139 | - if ($email) { |
|
| 140 | - ecrire_meta('email_webmaster', $email); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // Connecter directement celui qui vient de (re)donner son login |
|
| 144 | - // mais sans cookie d'admin ni connexion longue |
|
| 145 | - include_spip('inc/auth'); |
|
| 146 | - $auteur = auth_identifier_login($login, $pass); |
|
| 147 | - if (!$auteur || !auth_loger($auteur)) { |
|
| 148 | - spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // installer les metas |
|
| 153 | - $config = charger_fonction('config', 'inc'); |
|
| 154 | - $config(); |
|
| 155 | - |
|
| 156 | - // activer les plugins |
|
| 157 | - // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 158 | - // poursuivre au hit suivant |
|
| 159 | - include_spip('inc/plugin'); |
|
| 160 | - actualise_plugins_actifs(); |
|
| 161 | - |
|
| 162 | - |
|
| 163 | - include_spip('inc/distant'); |
|
| 164 | - redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 19 | + $auth_spip = null; |
|
| 20 | + $session = null; |
|
| 21 | + $row = null; |
|
| 22 | + $login = _request('login'); |
|
| 23 | + $email = _request('email'); |
|
| 24 | + $nom = _request('nom'); |
|
| 25 | + $pass = _request('pass'); |
|
| 26 | + $pass_verif = _request('pass_verif'); |
|
| 27 | + |
|
| 28 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 29 | + ? _INSTALL_SERVER_DB |
|
| 30 | + : _request('server_db'); |
|
| 31 | + |
|
| 32 | + if (!defined('_PASS_LONGUEUR_MINI')) { |
|
| 33 | + define('_PASS_LONGUEUR_MINI', 6); |
|
| 34 | + } |
|
| 35 | + if (!defined('_LOGIN_TROP_COURT')) { |
|
| 36 | + define('_LOGIN_TROP_COURT', 4); |
|
| 37 | + } |
|
| 38 | + if ($login) { |
|
| 39 | + $echec = ($pass != $pass_verif) ? |
|
| 40 | + _T('info_passes_identiques') |
|
| 41 | + : ((strlen((string) $pass) < _PASS_LONGUEUR_MINI) ? |
|
| 42 | + _T('info_passe_trop_court_car_pluriel', ['nb' => _PASS_LONGUEUR_MINI]) |
|
| 43 | + : ((strlen((string) $login) < _LOGIN_TROP_COURT) ? |
|
| 44 | + _T('info_login_trop_court') |
|
| 45 | + : '')); |
|
| 46 | + include_spip('inc/filtres'); |
|
| 47 | + if (!$echec && $email && !email_valide($email)) { |
|
| 48 | + $echec = _T('form_email_non_valide'); |
|
| 49 | + } |
|
| 50 | + if ($echec) { |
|
| 51 | + echouer_etape_3b($echec); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if (@file_exists(_FILE_CHMOD_TMP)) { |
|
| 56 | + include(_FILE_CHMOD_TMP); |
|
| 57 | + } else { |
|
| 58 | + redirige_url_ecrire('install'); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 62 | + redirige_url_ecrire('install'); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + # maintenant on connait le vrai charset du site s'il est deja configure |
|
| 66 | + # sinon par defaut lire_meta reglera _DEFAULT_CHARSET |
|
| 67 | + # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET) |
|
| 68 | + |
|
| 69 | + lire_metas(); |
|
| 70 | + if ($login) { |
|
| 71 | + include_spip('inc/charsets'); |
|
| 72 | + |
|
| 73 | + $nom = (importer_charset($nom, _DEFAULT_CHARSET)); |
|
| 74 | + $login = (importer_charset($login, _DEFAULT_CHARSET)); |
|
| 75 | + $email = (importer_charset($email, _DEFAULT_CHARSET)); |
|
| 76 | + |
|
| 77 | + include_spip('auth/spip'); |
|
| 78 | + // prelablement, creer le champ webmestre si il n'existe pas (install neuve |
|
| 79 | + // sur une vieille base |
|
| 80 | + $t = sql_showtable('spip_auteurs', true); |
|
| 81 | + if (!isset($t['field']['webmestre'])) { |
|
| 82 | + @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3) DEFAULT 'non' NOT NULL"); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + // il faut avoir une cle des auth valide pour creer un nouvel auteur webmestre |
|
| 86 | + $cles = \Spip\Chiffrer\SpipCles::instance(); |
|
| 87 | + $secret = $cles->getSecretAuth(); |
|
| 88 | + |
|
| 89 | + $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login)); |
|
| 90 | + if ($id_auteur !== null) { |
|
| 91 | + // c'est un auteur connu : si on a pas de secret il faut absolument qu'il se reconnecte avec le meme mot de passe |
|
| 92 | + // pour restaurer la copie des cles |
|
| 93 | + if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 94 | + $row = sql_fetsel('backup_cles, pass', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 95 | + if (empty($row['backup_cles']) || !$cles->restore($row['backup_cles'], $pass, $row['pass'], $id_auteur)) { |
|
| 96 | + $echec = _T('avis_connexion_erreur_fichier_cle_manquant_1'); |
|
| 97 | + echouer_etape_3b($echec); |
|
| 98 | + } |
|
| 99 | + spip_log("Les cles secretes ont ete restaurées avec le backup du webmestre #$id_auteur", 'auth' . _LOG_INFO_IMPORTANTE); |
|
| 100 | + $cles->save(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + sql_updateq('spip_auteurs', [ |
|
| 104 | + 'nom' => $nom, |
|
| 105 | + 'email' => $email, |
|
| 106 | + 'login' => $login, |
|
| 107 | + 'statut' => '0minirezo' |
|
| 108 | + ], 'id_auteur=' . (int) $id_auteur); |
|
| 109 | + // le passer webmestre separement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 110 | + @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 111 | + if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 112 | + $echec = _T('avis_erreur_creation_compte'); |
|
| 113 | + echouer_etape_3b($echec); |
|
| 114 | + } |
|
| 115 | + } else { |
|
| 116 | + // Si on a pas de cle et qu'on ne sait pas la creer, on ne peut pas creer de nouveau compte : |
|
| 117 | + // il faut qu'un webmestre avec un backup fasse l'install |
|
| 118 | + if (!$secret && !auth_spip_initialiser_secret()) { |
|
| 119 | + $echec = _T('avis_connexion_erreur_fichier_cle_manquant_2'); |
|
| 120 | + echouer_etape_3b($echec); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $id_auteur = sql_insertq('spip_auteurs', [ |
|
| 124 | + 'nom' => $nom, |
|
| 125 | + 'email' => $email, |
|
| 126 | + 'login' => $login, |
|
| 127 | + 'statut' => '0minirezo' |
|
| 128 | + ]); |
|
| 129 | + // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne |
|
| 130 | + @sql_updateq('spip_auteurs', ['webmestre' => 'oui'], "id_auteur=$id_auteur"); |
|
| 131 | + if (!auth_spip_modifier_pass($login, $pass, $id_auteur)) { |
|
| 132 | + $echec = _T('avis_erreur_creation_compte'); |
|
| 133 | + echouer_etape_3b($echec); |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // inserer email comme email webmaster principal |
|
| 138 | + // (sauf s'il est vide: cas de la re-installation) |
|
| 139 | + if ($email) { |
|
| 140 | + ecrire_meta('email_webmaster', $email); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // Connecter directement celui qui vient de (re)donner son login |
|
| 144 | + // mais sans cookie d'admin ni connexion longue |
|
| 145 | + include_spip('inc/auth'); |
|
| 146 | + $auteur = auth_identifier_login($login, $pass); |
|
| 147 | + if (!$auteur || !auth_loger($auteur)) { |
|
| 148 | + spip_log("login automatique impossible $auth_spip $session" . (is_countable($row) ? count($row) : 0)); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // installer les metas |
|
| 153 | + $config = charger_fonction('config', 'inc'); |
|
| 154 | + $config(); |
|
| 155 | + |
|
| 156 | + // activer les plugins |
|
| 157 | + // leur installation ne peut pas se faire sur le meme hit, il faudra donc |
|
| 158 | + // poursuivre au hit suivant |
|
| 159 | + include_spip('inc/plugin'); |
|
| 160 | + actualise_plugins_actifs(); |
|
| 161 | + |
|
| 162 | + |
|
| 163 | + include_spip('inc/distant'); |
|
| 164 | + redirige_par_entete(parametre_url(self(), 'etape', '4', '&')); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | function echouer_etape_3b($echec): never { |
| 168 | - echo minipres( |
|
| 169 | - 'AUTO', |
|
| 170 | - info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 171 | - "<div class='error'><h3>$echec</h3>\n" . |
|
| 172 | - '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 173 | - '</div>' |
|
| 174 | - ); |
|
| 175 | - exit; |
|
| 168 | + echo minipres( |
|
| 169 | + 'AUTO', |
|
| 170 | + info_progression_etape(3, 'etape_', 'install/', true) . |
|
| 171 | + "<div class='error'><h3>$echec</h3>\n" . |
|
| 172 | + '<p>' . _T('avis_connexion_echec_2') . '</p>' . |
|
| 173 | + '</div>' |
|
| 174 | + ); |
|
| 175 | + exit; |
|
| 176 | 176 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | include_spip('inc/charsets'); |
| 16 | 16 | |
@@ -26,90 +26,90 @@ discard block |
||
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | 28 | function plugins_afficher_liste_dist( |
| 29 | - $url_page, |
|
| 30 | - $liste_plugins, |
|
| 31 | - $liste_plugins_checked, |
|
| 32 | - $liste_plugins_actifs, |
|
| 33 | - $dir_plugins = _DIR_PLUGINS, |
|
| 34 | - $afficher_un = 'afficher_plugin' |
|
| 29 | + $url_page, |
|
| 30 | + $liste_plugins, |
|
| 31 | + $liste_plugins_checked, |
|
| 32 | + $liste_plugins_actifs, |
|
| 33 | + $dir_plugins = _DIR_PLUGINS, |
|
| 34 | + $afficher_un = 'afficher_plugin' |
|
| 35 | 35 | ) { |
| 36 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 37 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 36 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 37 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 38 | 38 | |
| 39 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 39 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 40 | 40 | |
| 41 | - $all_infos = pipeline( |
|
| 42 | - 'filtrer_liste_plugins', |
|
| 43 | - [ |
|
| 44 | - 'args' => [ |
|
| 45 | - 'liste_plugins' => $liste_plugins, |
|
| 46 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 47 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 48 | - 'dir_plugins' => $dir_plugins |
|
| 49 | - ], |
|
| 50 | - 'data' => $all_infos |
|
| 51 | - ] |
|
| 52 | - ); |
|
| 41 | + $all_infos = pipeline( |
|
| 42 | + 'filtrer_liste_plugins', |
|
| 43 | + [ |
|
| 44 | + 'args' => [ |
|
| 45 | + 'liste_plugins' => $liste_plugins, |
|
| 46 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 47 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 48 | + 'dir_plugins' => $dir_plugins |
|
| 49 | + ], |
|
| 50 | + 'data' => $all_infos |
|
| 51 | + ] |
|
| 52 | + ); |
|
| 53 | 53 | |
| 54 | - $liste_plugins = array_flip($liste_plugins); |
|
| 55 | - foreach (array_keys($liste_plugins) as $chemin) { |
|
| 56 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 57 | - if (isset($all_infos[$chemin])) { |
|
| 58 | - $liste_plugins[$chemin] = strtoupper(trim((string) typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 59 | - } else { |
|
| 60 | - unset($liste_plugins[$chemin]); |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - asort($liste_plugins); |
|
| 64 | - $exposed = urldecode(_request('plugin') ?? ''); |
|
| 54 | + $liste_plugins = array_flip($liste_plugins); |
|
| 55 | + foreach (array_keys($liste_plugins) as $chemin) { |
|
| 56 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 57 | + if (isset($all_infos[$chemin])) { |
|
| 58 | + $liste_plugins[$chemin] = strtoupper(trim((string) typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 59 | + } else { |
|
| 60 | + unset($liste_plugins[$chemin]); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + asort($liste_plugins); |
|
| 64 | + $exposed = urldecode(_request('plugin') ?? ''); |
|
| 65 | 65 | |
| 66 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | - $fast_liste_plugins_actifs = []; |
|
| 68 | - $fast_liste_plugins_checked = []; |
|
| 69 | - if (is_array($liste_plugins_actifs)) { |
|
| 70 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 71 | - } |
|
| 72 | - if (is_array($liste_plugins_checked)) { |
|
| 73 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 74 | - } |
|
| 66 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | + $fast_liste_plugins_actifs = []; |
|
| 68 | + $fast_liste_plugins_checked = []; |
|
| 69 | + if (is_array($liste_plugins_actifs)) { |
|
| 70 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 71 | + } |
|
| 72 | + if (is_array($liste_plugins_checked)) { |
|
| 73 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $res = ''; |
|
| 77 | - $block = ''; |
|
| 78 | - $initiale = ''; |
|
| 79 | - $block_actif = false; |
|
| 80 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 81 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 82 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 83 | - $initiale = $i; |
|
| 84 | - $block = ''; |
|
| 85 | - $block_actif = false; |
|
| 86 | - } |
|
| 87 | - // le rep suivant |
|
| 88 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 89 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 90 | - $block_actif |= $actif; |
|
| 91 | - $expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr( |
|
| 92 | - $dir_plugins, |
|
| 93 | - strlen(_DIR_RACINE) |
|
| 94 | - ) . $plug)); |
|
| 95 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 96 | - } |
|
| 97 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 98 | - $class = basename($dir_plugins); |
|
| 76 | + $res = ''; |
|
| 77 | + $block = ''; |
|
| 78 | + $initiale = ''; |
|
| 79 | + $block_actif = false; |
|
| 80 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 81 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 82 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 83 | + $initiale = $i; |
|
| 84 | + $block = ''; |
|
| 85 | + $block_actif = false; |
|
| 86 | + } |
|
| 87 | + // le rep suivant |
|
| 88 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 89 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 90 | + $block_actif |= $actif; |
|
| 91 | + $expose = ($exposed && ($exposed == $plug || $exposed === $dir_plugins . $plug || $exposed === substr( |
|
| 92 | + $dir_plugins, |
|
| 93 | + strlen(_DIR_RACINE) |
|
| 94 | + ) . $plug)); |
|
| 95 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 96 | + } |
|
| 97 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 98 | + $class = basename($dir_plugins); |
|
| 99 | 99 | |
| 100 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 100 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 105 | - if (strlen((string) $block)) { |
|
| 106 | - return "<li class='item'>" |
|
| 107 | - . bouton_block_depliable($initiale, (bool) $block_actif) |
|
| 108 | - . debut_block_depliable($block_actif) |
|
| 109 | - . "<ul>$block</ul>" |
|
| 110 | - . fin_block() |
|
| 111 | - . '</li>'; |
|
| 112 | - } |
|
| 105 | + if (strlen((string) $block)) { |
|
| 106 | + return "<li class='item'>" |
|
| 107 | + . bouton_block_depliable($initiale, (bool) $block_actif) |
|
| 108 | + . debut_block_depliable($block_actif) |
|
| 109 | + . "<ul>$block</ul>" |
|
| 110 | + . fin_block() |
|
| 111 | + . '</li>'; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return ''; |
|
| 114 | + return ''; |
|
| 115 | 115 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -20,28 +20,28 @@ discard block |
||
| 20 | 20 | * @param array $arbre |
| 21 | 21 | */ |
| 22 | 22 | function plugins_extraire_pipelines_dist(&$arbre) { |
| 23 | - $pipes = null; |
|
| 24 | - $tag = null; |
|
| 25 | - $pipeline = []; |
|
| 26 | - if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 27 | - foreach ($pipes as $tag => $p) { |
|
| 28 | - if (!is_array($p[0])) { |
|
| 29 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 30 | - $pipeline[] = $att; |
|
| 31 | - } else { |
|
| 32 | - foreach ($p as $pipe) { |
|
| 33 | - $att = []; |
|
| 34 | - if (is_array($pipe)) { |
|
| 35 | - foreach ($pipe as $k => $t) { |
|
| 36 | - $att[$k] = trim((string) end($t)); |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - $pipeline[] = $att; |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - unset($arbre[$tag]); |
|
| 44 | - } |
|
| 23 | + $pipes = null; |
|
| 24 | + $tag = null; |
|
| 25 | + $pipeline = []; |
|
| 26 | + if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 27 | + foreach ($pipes as $tag => $p) { |
|
| 28 | + if (!is_array($p[0])) { |
|
| 29 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 30 | + $pipeline[] = $att; |
|
| 31 | + } else { |
|
| 32 | + foreach ($p as $pipe) { |
|
| 33 | + $att = []; |
|
| 34 | + if (is_array($pipe)) { |
|
| 35 | + foreach ($pipe as $k => $t) { |
|
| 36 | + $att[$k] = trim((string) end($t)); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + $pipeline[] = $att; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + unset($arbre[$tag]); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - return $pipeline; |
|
| 46 | + return $pipeline; |
|
| 47 | 47 | } |
@@ -10,207 +10,207 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | include_spip('inc/xml'); |
| 17 | 17 | include_spip('inc/plugin'); |
| 18 | 18 | |
| 19 | 19 | function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) { |
| 20 | - $needs = null; |
|
| 21 | - $compat_spip = null; |
|
| 22 | - $uses = null; |
|
| 23 | - $paths = null; |
|
| 24 | - $trads = null; |
|
| 25 | - static $etats = ['dev', 'experimental', 'test', 'stable']; |
|
| 20 | + $needs = null; |
|
| 21 | + $compat_spip = null; |
|
| 22 | + $uses = null; |
|
| 23 | + $paths = null; |
|
| 24 | + $trads = null; |
|
| 25 | + static $etats = ['dev', 'experimental', 'test', 'stable']; |
|
| 26 | 26 | |
| 27 | - $matches = []; |
|
| 28 | - $silence = false; |
|
| 29 | - $p = null; |
|
| 30 | - // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 31 | - if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) { |
|
| 32 | - // version de SPIP |
|
| 33 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 34 | - foreach ($matches as $tag => $sous) { |
|
| 35 | - [$tagname, $atts] = spip_xml_decompose_tag($tag); |
|
| 36 | - // On rajoute la condition sur $n : |
|
| 37 | - // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 38 | - // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 39 | - // de la meme facon. |
|
| 40 | - if ( |
|
| 41 | - $tagname == 'plugin' |
|
| 42 | - && is_array($sous) |
|
| 43 | - && (!isset($atts['spip']) || $n == 1 || plugin_version_compatible($atts['spip'], $vspip, 'spip')) |
|
| 44 | - ) { |
|
| 45 | - // on prend la derniere declaration avec ce nom |
|
| 46 | - $p = end($sous); |
|
| 47 | - $compat_spip = $atts['spip'] ?? ''; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - if (is_null($p)) { |
|
| 52 | - $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 53 | - $silence = true; |
|
| 54 | - } else { |
|
| 55 | - $arbre = $p; |
|
| 56 | - } |
|
| 57 | - if (!is_array($arbre)) { |
|
| 58 | - $arbre = []; |
|
| 59 | - } |
|
| 60 | - // verification de la conformite du plugin avec quelques |
|
| 61 | - // precautions elementaires |
|
| 62 | - if (!isset($arbre['nom'])) { |
|
| 63 | - if (!$silence) { |
|
| 64 | - $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 65 | - } |
|
| 66 | - $arbre['nom'] = ['']; |
|
| 67 | - } |
|
| 68 | - if (!isset($arbre['version'])) { |
|
| 69 | - if (!$silence) { |
|
| 70 | - $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 71 | - } |
|
| 72 | - $arbre['version'] = ['']; |
|
| 73 | - } |
|
| 74 | - if (!isset($arbre['prefix'])) { |
|
| 75 | - if (!$silence) { |
|
| 76 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 77 | - } |
|
| 78 | - $arbre['prefix'] = ['']; |
|
| 79 | - } else { |
|
| 80 | - $prefix = trim((string) end($arbre['prefix'])); |
|
| 81 | - if (strtoupper($prefix) == 'SPIP' && $plug != './') { |
|
| 82 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 83 | - } |
|
| 84 | - if (isset($arbre['etat'])) { |
|
| 85 | - $etat = trim((string) end($arbre['etat'])); |
|
| 86 | - if (!in_array($etat, $etats)) { |
|
| 87 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - if (isset($arbre['options'])) { |
|
| 91 | - foreach ($arbre['options'] as $optfile) { |
|
| 92 | - $optfile = trim((string) $optfile); |
|
| 93 | - if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 94 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - if (isset($arbre['fonctions'])) { |
|
| 99 | - foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | - $optfile = trim((string) $optfile); |
|
| 101 | - if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 102 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - $fonctions = []; |
|
| 107 | - if (isset($arbre['fonctions'])) { |
|
| 108 | - $fonctions = $arbre['fonctions']; |
|
| 109 | - } |
|
| 110 | - $liste_methodes_reservees = [ |
|
| 111 | - '__construct', |
|
| 112 | - '__destruct', |
|
| 113 | - 'plugin', |
|
| 114 | - 'install', |
|
| 115 | - 'uninstall', |
|
| 116 | - strtolower($prefix) |
|
| 117 | - ]; |
|
| 27 | + $matches = []; |
|
| 28 | + $silence = false; |
|
| 29 | + $p = null; |
|
| 30 | + // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 31 | + if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) { |
|
| 32 | + // version de SPIP |
|
| 33 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 34 | + foreach ($matches as $tag => $sous) { |
|
| 35 | + [$tagname, $atts] = spip_xml_decompose_tag($tag); |
|
| 36 | + // On rajoute la condition sur $n : |
|
| 37 | + // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 38 | + // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 39 | + // de la meme facon. |
|
| 40 | + if ( |
|
| 41 | + $tagname == 'plugin' |
|
| 42 | + && is_array($sous) |
|
| 43 | + && (!isset($atts['spip']) || $n == 1 || plugin_version_compatible($atts['spip'], $vspip, 'spip')) |
|
| 44 | + ) { |
|
| 45 | + // on prend la derniere declaration avec ce nom |
|
| 46 | + $p = end($sous); |
|
| 47 | + $compat_spip = $atts['spip'] ?? ''; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + if (is_null($p)) { |
|
| 52 | + $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 53 | + $silence = true; |
|
| 54 | + } else { |
|
| 55 | + $arbre = $p; |
|
| 56 | + } |
|
| 57 | + if (!is_array($arbre)) { |
|
| 58 | + $arbre = []; |
|
| 59 | + } |
|
| 60 | + // verification de la conformite du plugin avec quelques |
|
| 61 | + // precautions elementaires |
|
| 62 | + if (!isset($arbre['nom'])) { |
|
| 63 | + if (!$silence) { |
|
| 64 | + $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 65 | + } |
|
| 66 | + $arbre['nom'] = ['']; |
|
| 67 | + } |
|
| 68 | + if (!isset($arbre['version'])) { |
|
| 69 | + if (!$silence) { |
|
| 70 | + $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 71 | + } |
|
| 72 | + $arbre['version'] = ['']; |
|
| 73 | + } |
|
| 74 | + if (!isset($arbre['prefix'])) { |
|
| 75 | + if (!$silence) { |
|
| 76 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 77 | + } |
|
| 78 | + $arbre['prefix'] = ['']; |
|
| 79 | + } else { |
|
| 80 | + $prefix = trim((string) end($arbre['prefix'])); |
|
| 81 | + if (strtoupper($prefix) == 'SPIP' && $plug != './') { |
|
| 82 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 83 | + } |
|
| 84 | + if (isset($arbre['etat'])) { |
|
| 85 | + $etat = trim((string) end($arbre['etat'])); |
|
| 86 | + if (!in_array($etat, $etats)) { |
|
| 87 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + if (isset($arbre['options'])) { |
|
| 91 | + foreach ($arbre['options'] as $optfile) { |
|
| 92 | + $optfile = trim((string) $optfile); |
|
| 93 | + if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 94 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + if (isset($arbre['fonctions'])) { |
|
| 99 | + foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | + $optfile = trim((string) $optfile); |
|
| 101 | + if (!@is_readable($dir_plugins . "$plug/$optfile") && !$silence) { |
|
| 102 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + $fonctions = []; |
|
| 107 | + if (isset($arbre['fonctions'])) { |
|
| 108 | + $fonctions = $arbre['fonctions']; |
|
| 109 | + } |
|
| 110 | + $liste_methodes_reservees = [ |
|
| 111 | + '__construct', |
|
| 112 | + '__destruct', |
|
| 113 | + 'plugin', |
|
| 114 | + 'install', |
|
| 115 | + 'uninstall', |
|
| 116 | + strtolower($prefix) |
|
| 117 | + ]; |
|
| 118 | 118 | |
| 119 | - $extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins'); |
|
| 120 | - $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 121 | - foreach ($arbre['pipeline'] as $pipe) { |
|
| 122 | - if (!isset($pipe['nom']) && !$silence) { |
|
| 123 | - $arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini'); |
|
| 124 | - } |
|
| 125 | - $action = $pipe['action'] ?? $pipe['nom']; |
|
| 126 | - // verif que la methode a un nom autorise |
|
| 127 | - if (in_array(strtolower((string) $action), $liste_methodes_reservees) && !$silence) { |
|
| 128 | - $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 129 | - } |
|
| 130 | - if (isset($pipe['inclure'])) { |
|
| 131 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 132 | - if (!@is_readable($inclure) && !$silence) { |
|
| 133 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - $necessite = []; |
|
| 138 | - $spip_trouve = false; |
|
| 139 | - if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 140 | - foreach (array_keys($needs) as $tag) { |
|
| 141 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 142 | - if (!isset($att['id'])) { |
|
| 143 | - if (!$silence) { |
|
| 144 | - $arbre['erreur'][] = _T( |
|
| 145 | - 'erreur_plugin_attribut_balise_manquant', |
|
| 146 | - ['attribut' => 'id', 'balise' => $att] |
|
| 147 | - ); |
|
| 148 | - } |
|
| 149 | - } else { |
|
| 150 | - $necessite[] = $att; |
|
| 151 | - } |
|
| 152 | - if (strtolower((string) $att['id']) == 'spip') { |
|
| 153 | - $spip_trouve = true; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - if ($compat_spip && !$spip_trouve) { |
|
| 158 | - $necessite[] = ['id' => 'spip', 'version' => $compat_spip]; |
|
| 159 | - } |
|
| 160 | - $arbre['necessite'] = $necessite; |
|
| 161 | - $utilise = []; |
|
| 162 | - if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 163 | - foreach (array_keys($uses) as $tag) { |
|
| 164 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 165 | - if (!isset($att['id'])) { |
|
| 166 | - if (!$silence) { |
|
| 167 | - $arbre['erreur'][] = _T( |
|
| 168 | - 'erreur_plugin_attribut_balise_manquant', |
|
| 169 | - ['attribut' => 'id', 'balise' => $att] |
|
| 170 | - ); |
|
| 171 | - } |
|
| 172 | - } else { |
|
| 173 | - $utilise[] = $att; |
|
| 174 | - } |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - $arbre['utilise'] = $utilise; |
|
| 178 | - $procure = []; |
|
| 179 | - if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 180 | - foreach (array_keys($uses) as $tag) { |
|
| 181 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 182 | - $procure[] = $att; |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $arbre['procure'] = $procure; |
|
| 186 | - $path = []; |
|
| 187 | - if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 188 | - foreach (array_keys($paths) as $tag) { |
|
| 189 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 190 | - $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 191 | - $path[] = $att; |
|
| 192 | - } |
|
| 193 | - } else { |
|
| 194 | - $path = [['dir' => '']]; |
|
| 195 | - } // initialiser par defaut |
|
| 196 | - $arbre['path'] = $path; |
|
| 197 | - // exposer les noisettes |
|
| 198 | - if (isset($arbre['noisette'])) { |
|
| 199 | - foreach ($arbre['noisette'] as $k => $nut) { |
|
| 200 | - $nut = preg_replace(',[.]html$,uims', '', trim((string) $nut)); |
|
| 201 | - $arbre['noisette'][$k] = $nut; |
|
| 202 | - if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) { |
|
| 203 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 204 | - } |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - $traduire = []; |
|
| 208 | - if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 209 | - foreach (array_keys($trads) as $tag) { |
|
| 210 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 211 | - $traduire[] = $att; |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - $arbre['traduire'] = $traduire; |
|
| 215 | - } |
|
| 119 | + $extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins'); |
|
| 120 | + $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 121 | + foreach ($arbre['pipeline'] as $pipe) { |
|
| 122 | + if (!isset($pipe['nom']) && !$silence) { |
|
| 123 | + $arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini'); |
|
| 124 | + } |
|
| 125 | + $action = $pipe['action'] ?? $pipe['nom']; |
|
| 126 | + // verif que la methode a un nom autorise |
|
| 127 | + if (in_array(strtolower((string) $action), $liste_methodes_reservees) && !$silence) { |
|
| 128 | + $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 129 | + } |
|
| 130 | + if (isset($pipe['inclure'])) { |
|
| 131 | + $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 132 | + if (!@is_readable($inclure) && !$silence) { |
|
| 133 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + $necessite = []; |
|
| 138 | + $spip_trouve = false; |
|
| 139 | + if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 140 | + foreach (array_keys($needs) as $tag) { |
|
| 141 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 142 | + if (!isset($att['id'])) { |
|
| 143 | + if (!$silence) { |
|
| 144 | + $arbre['erreur'][] = _T( |
|
| 145 | + 'erreur_plugin_attribut_balise_manquant', |
|
| 146 | + ['attribut' => 'id', 'balise' => $att] |
|
| 147 | + ); |
|
| 148 | + } |
|
| 149 | + } else { |
|
| 150 | + $necessite[] = $att; |
|
| 151 | + } |
|
| 152 | + if (strtolower((string) $att['id']) == 'spip') { |
|
| 153 | + $spip_trouve = true; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + if ($compat_spip && !$spip_trouve) { |
|
| 158 | + $necessite[] = ['id' => 'spip', 'version' => $compat_spip]; |
|
| 159 | + } |
|
| 160 | + $arbre['necessite'] = $necessite; |
|
| 161 | + $utilise = []; |
|
| 162 | + if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 163 | + foreach (array_keys($uses) as $tag) { |
|
| 164 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 165 | + if (!isset($att['id'])) { |
|
| 166 | + if (!$silence) { |
|
| 167 | + $arbre['erreur'][] = _T( |
|
| 168 | + 'erreur_plugin_attribut_balise_manquant', |
|
| 169 | + ['attribut' => 'id', 'balise' => $att] |
|
| 170 | + ); |
|
| 171 | + } |
|
| 172 | + } else { |
|
| 173 | + $utilise[] = $att; |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + $arbre['utilise'] = $utilise; |
|
| 178 | + $procure = []; |
|
| 179 | + if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 180 | + foreach (array_keys($uses) as $tag) { |
|
| 181 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 182 | + $procure[] = $att; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $arbre['procure'] = $procure; |
|
| 186 | + $path = []; |
|
| 187 | + if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 188 | + foreach (array_keys($paths) as $tag) { |
|
| 189 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 190 | + $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 191 | + $path[] = $att; |
|
| 192 | + } |
|
| 193 | + } else { |
|
| 194 | + $path = [['dir' => '']]; |
|
| 195 | + } // initialiser par defaut |
|
| 196 | + $arbre['path'] = $path; |
|
| 197 | + // exposer les noisettes |
|
| 198 | + if (isset($arbre['noisette'])) { |
|
| 199 | + foreach ($arbre['noisette'] as $k => $nut) { |
|
| 200 | + $nut = preg_replace(',[.]html$,uims', '', trim((string) $nut)); |
|
| 201 | + $arbre['noisette'][$k] = $nut; |
|
| 202 | + if (!@is_readable($dir_plugins . "$plug/$nut.html") && !$silence) { |
|
| 203 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 204 | + } |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + $traduire = []; |
|
| 208 | + if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 209 | + foreach (array_keys($trads) as $tag) { |
|
| 210 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 211 | + $traduire[] = $att; |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + $arbre['traduire'] = $traduire; |
|
| 215 | + } |
|
| 216 | 216 | } |