@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -32,32 +32,32 @@ discard block |
||
| 32 | 32 | * @return int |
| 33 | 33 | */ |
| 34 | 34 | function genie_mail_dist($t) { |
| 35 | - $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 36 | - $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 37 | - |
|
| 38 | - $now = time(); |
|
| 39 | - if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 40 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - $page = recuperer_fond('nouveautes', |
|
| 44 | - array('date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf), array('raw' => true)); |
|
| 45 | - |
|
| 46 | - if (strlen(trim($page['texte']))) { |
|
| 47 | - // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 48 | - $headers = ""; |
|
| 49 | - if (isset($page['entetes']) and count($page['entetes'])) { |
|
| 50 | - foreach ($page['entetes'] as $k => $v) { |
|
| 51 | - $headers .= (strlen($v) ? "$k: $v" : $k) . "\n"; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - include_spip("inc/notifications"); |
|
| 56 | - notifications_envoyer_mails($adresse_neuf, $page['texte'], "", "", $headers); |
|
| 57 | - ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 58 | - } else { |
|
| 59 | - spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - return 1; |
|
| 35 | + $adresse_neuf = $GLOBALS['meta']['adresse_neuf']; |
|
| 36 | + $jours_neuf = $GLOBALS['meta']['jours_neuf']; |
|
| 37 | + |
|
| 38 | + $now = time(); |
|
| 39 | + if (!isset($GLOBALS['meta']['dernier_envoi_neuf'])) { |
|
| 40 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now - (3600 * 24 * $jours_neuf))); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + $page = recuperer_fond('nouveautes', |
|
| 44 | + array('date' => $GLOBALS['meta']['dernier_envoi_neuf'], 'jours_neuf' => $jours_neuf), array('raw' => true)); |
|
| 45 | + |
|
| 46 | + if (strlen(trim($page['texte']))) { |
|
| 47 | + // recuperer les entetes envoyes par #HTTP_HEADER |
|
| 48 | + $headers = ""; |
|
| 49 | + if (isset($page['entetes']) and count($page['entetes'])) { |
|
| 50 | + foreach ($page['entetes'] as $k => $v) { |
|
| 51 | + $headers .= (strlen($v) ? "$k: $v" : $k) . "\n"; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + include_spip("inc/notifications"); |
|
| 56 | + notifications_envoyer_mails($adresse_neuf, $page['texte'], "", "", $headers); |
|
| 57 | + ecrire_meta('dernier_envoi_neuf', date('Y-m-d H:i:s', $now)); |
|
| 58 | + } else { |
|
| 59 | + spip_log("mail nouveautes : rien de neuf depuis $jours_neuf jours"); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + return 1; |
|
| 63 | 63 | } |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $headers = ""; |
| 49 | 49 | if (isset($page['entetes']) and count($page['entetes'])) { |
| 50 | 50 | foreach ($page['entetes'] as $k => $v) { |
| 51 | - $headers .= (strlen($v) ? "$k: $v" : $k) . "\n"; |
|
| 51 | + $headers .= (strlen($v) ? "$k: $v" : $k)."\n"; |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
@@ -11,74 +11,74 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Correction typographique francaise |
| 18 | 18 | |
| 19 | 19 | function typographie_fr_dist($letexte) { |
| 20 | 20 | |
| 21 | - static $trans; |
|
| 21 | + static $trans; |
|
| 22 | 22 | |
| 23 | - // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ; |
|
| 24 | - // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe |
|
| 25 | - if (!$trans) { |
|
| 26 | - $trans = array( |
|
| 27 | - "'" => '’', |
|
| 28 | - ' ' => '~', |
|
| 29 | - '»' => '»', |
|
| 30 | - '«' => '«', |
|
| 31 | - '”' => '”', |
|
| 32 | - '“' => '“', |
|
| 33 | - '°' => '°' |
|
| 34 | - ); |
|
| 35 | - $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°'); |
|
| 36 | - $chars_trans = array_keys($chars); |
|
| 37 | - $chars = array_values($chars); |
|
| 38 | - $chars_trans = implode(' ', array_map('chr', $chars_trans)); |
|
| 39 | - $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer')); |
|
| 40 | - $chars_trans = explode(' ', $chars_trans); |
|
| 41 | - foreach ($chars as $k => $r) { |
|
| 42 | - $trans[$chars_trans[$k]] = $r; |
|
| 43 | - } |
|
| 44 | - } |
|
| 23 | + // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ; |
|
| 24 | + // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe |
|
| 25 | + if (!$trans) { |
|
| 26 | + $trans = array( |
|
| 27 | + "'" => '’', |
|
| 28 | + ' ' => '~', |
|
| 29 | + '»' => '»', |
|
| 30 | + '«' => '«', |
|
| 31 | + '”' => '”', |
|
| 32 | + '“' => '“', |
|
| 33 | + '°' => '°' |
|
| 34 | + ); |
|
| 35 | + $chars = array(160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°'); |
|
| 36 | + $chars_trans = array_keys($chars); |
|
| 37 | + $chars = array_values($chars); |
|
| 38 | + $chars_trans = implode(' ', array_map('chr', $chars_trans)); |
|
| 39 | + $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer')); |
|
| 40 | + $chars_trans = explode(' ', $chars_trans); |
|
| 41 | + foreach ($chars as $k => $r) { |
|
| 42 | + $trans[$chars_trans[$k]] = $r; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - $letexte = strtr($letexte, $trans); |
|
| 46 | + $letexte = strtr($letexte, $trans); |
|
| 47 | 47 | |
| 48 | - $cherche1 = array( |
|
| 49 | - /* 1 */ |
|
| 50 | - '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S', |
|
| 51 | - /* 2 */ |
|
| 52 | - '/»| --?,|(?::(?!:)| %)(?:\W|$)/S', |
|
| 53 | - /* 3 */ |
|
| 54 | - '/([^[<(!?.])([!?][!?\.]*)/iS', |
|
| 55 | - /* 4 */ |
|
| 56 | - '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S' |
|
| 57 | - ); |
|
| 58 | - $remplace1 = array( |
|
| 59 | - /* 1 */ |
|
| 60 | - '\1~;', |
|
| 61 | - /* 2 */ |
|
| 62 | - '~\0', |
|
| 63 | - /* 3 */ |
|
| 64 | - '\1~\2', |
|
| 65 | - /* 4 */ |
|
| 66 | - '\0~' |
|
| 67 | - ); |
|
| 68 | - $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 69 | - $letexte = preg_replace('/ *~+ */S', '~', $letexte); |
|
| 48 | + $cherche1 = array( |
|
| 49 | + /* 1 */ |
|
| 50 | + '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S', |
|
| 51 | + /* 2 */ |
|
| 52 | + '/»| --?,|(?::(?!:)| %)(?:\W|$)/S', |
|
| 53 | + /* 3 */ |
|
| 54 | + '/([^[<(!?.])([!?][!?\.]*)/iS', |
|
| 55 | + /* 4 */ |
|
| 56 | + '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S' |
|
| 57 | + ); |
|
| 58 | + $remplace1 = array( |
|
| 59 | + /* 1 */ |
|
| 60 | + '\1~;', |
|
| 61 | + /* 2 */ |
|
| 62 | + '~\0', |
|
| 63 | + /* 3 */ |
|
| 64 | + '\1~\2', |
|
| 65 | + /* 4 */ |
|
| 66 | + '\0~' |
|
| 67 | + ); |
|
| 68 | + $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 69 | + $letexte = preg_replace('/ *~+ */S', '~', $letexte); |
|
| 70 | 70 | |
| 71 | - $cherche2 = array( |
|
| 72 | - '/([^-\n]|^)--([^-]|$)/S', |
|
| 73 | - ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | - '/~/' |
|
| 75 | - ); |
|
| 76 | - $remplace2 = array( |
|
| 77 | - '\1—\2', |
|
| 78 | - '\1\3\4', |
|
| 79 | - ' ' |
|
| 80 | - ); |
|
| 81 | - $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 71 | + $cherche2 = array( |
|
| 72 | + '/([^-\n]|^)--([^-]|$)/S', |
|
| 73 | + ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | + '/~/' |
|
| 75 | + ); |
|
| 76 | + $remplace2 = array( |
|
| 77 | + '\1—\2', |
|
| 78 | + '\1\3\4', |
|
| 79 | + ' ' |
|
| 80 | + ); |
|
| 81 | + $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 82 | 82 | |
| 83 | - return $letexte; |
|
| 83 | + return $letexte; |
|
| 84 | 84 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | |
| 71 | 71 | $cherche2 = array( |
| 72 | 72 | '/([^-\n]|^)--([^-]|$)/S', |
| 73 | - ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 73 | + ',('._PROTOCOLES_STD.')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | 74 | '/~/' |
| 75 | 75 | ); |
| 76 | 76 | $remplace2 = array( |
@@ -11,37 +11,37 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // rien sauf les "~" et "-," |
| 18 | 18 | |
| 19 | 19 | function typographie_en_dist($letexte) { |
| 20 | 20 | |
| 21 | - // zouli apostrophe |
|
| 22 | - $letexte = str_replace("'", '’', $letexte); |
|
| 21 | + // zouli apostrophe |
|
| 22 | + $letexte = str_replace("'", '’', $letexte); |
|
| 23 | 23 | |
| 24 | - $cherche1 = array( |
|
| 25 | - '/ --?,/S' |
|
| 26 | - ); |
|
| 27 | - $remplace1 = array( |
|
| 28 | - '~\0' |
|
| 29 | - ); |
|
| 30 | - $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 24 | + $cherche1 = array( |
|
| 25 | + '/ --?,/S' |
|
| 26 | + ); |
|
| 27 | + $remplace1 = array( |
|
| 28 | + '~\0' |
|
| 29 | + ); |
|
| 30 | + $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 31 | 31 | |
| 32 | - $letexte = str_replace(' ', '~', $letexte); |
|
| 33 | - $letexte = preg_replace('/ *~+ */', '~', $letexte); |
|
| 32 | + $letexte = str_replace(' ', '~', $letexte); |
|
| 33 | + $letexte = preg_replace('/ *~+ */', '~', $letexte); |
|
| 34 | 34 | |
| 35 | - $cherche2 = array( |
|
| 36 | - '/([^-\n]|^)--([^-]|$)/', |
|
| 37 | - '/~/' |
|
| 38 | - ); |
|
| 39 | - $remplace2 = array( |
|
| 40 | - '\1—\2', |
|
| 41 | - ' ' |
|
| 42 | - ); |
|
| 35 | + $cherche2 = array( |
|
| 36 | + '/([^-\n]|^)--([^-]|$)/', |
|
| 37 | + '/~/' |
|
| 38 | + ); |
|
| 39 | + $remplace2 = array( |
|
| 40 | + '\1—\2', |
|
| 41 | + ' ' |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | - $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 44 | + $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 45 | 45 | |
| 46 | - return $letexte; |
|
| 46 | + return $letexte; |
|
| 47 | 47 | } |
@@ -73,5 +73,5 @@ |
||
| 73 | 73 | return ''; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - return generer_url_action('logout', "logout=public&url=" . rawurlencode($cible ? $cible : self('&'))); |
|
| 76 | + return generer_url_action('logout', "logout=public&url=".rawurlencode($cible ? $cible : self('&'))); |
|
| 77 | 77 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * Pile complétée du code compilé |
| 37 | 37 | **/ |
| 38 | 38 | function balise_URL_LOGOUT($p) { |
| 39 | - return calculer_balise_dynamique($p, 'URL_LOGOUT', array()); |
|
| 39 | + return calculer_balise_dynamique($p, 'URL_LOGOUT', array()); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * Liste (url) des arguments collectés. |
| 53 | 53 | */ |
| 54 | 54 | function balise_URL_LOGOUT_stat($args, $context_compil) { |
| 55 | - $url = isset($args[0]) ? $args[0] : ''; |
|
| 55 | + $url = isset($args[0]) ? $args[0] : ''; |
|
| 56 | 56 | |
| 57 | - return array($url); |
|
| 57 | + return array($url); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | **/ |
| 70 | 70 | function balise_URL_LOGOUT_dyn($cible) { |
| 71 | 71 | |
| 72 | - if (empty($GLOBALS['visiteur_session']['login']) and empty($GLOBALS['visiteur_session']['statut'])) { |
|
| 73 | - return ''; |
|
| 74 | - } |
|
| 72 | + if (empty($GLOBALS['visiteur_session']['login']) and empty($GLOBALS['visiteur_session']['statut'])) { |
|
| 73 | + return ''; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return generer_url_action('logout', "logout=public&url=" . rawurlencode($cible ? $cible : self('&'))); |
|
| 76 | + return generer_url_action('logout', "logout=public&url=" . rawurlencode($cible ? $cible : self('&'))); |
|
| 77 | 77 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG_ECRIRE($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', array('lang')); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG_ECRIRE', array('lang')); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | * Liste (lang) des arguments collectés et fournis. |
| 56 | 56 | */ |
| 57 | 57 | function balise_MENU_LANG_ECRIRE_stat($args, $context_compil) { |
| 58 | - include_spip('inc/lang'); |
|
| 59 | - if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 60 | - return ''; |
|
| 61 | - } |
|
| 58 | + include_spip('inc/lang'); |
|
| 59 | + if (strpos($GLOBALS['meta']['langues_proposees'], ',') === false) { |
|
| 60 | + return ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return $args; |
|
| 63 | + return $args; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * Liste : Chemin du squelette, durée du cache, contexte |
| 77 | 77 | **/ |
| 78 | 78 | function balise_MENU_LANG_ECRIRE_dyn($opt) { |
| 79 | - return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 79 | + return menu_lang_pour_tous('var_lang_ecrire', $opt); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -96,30 +96,30 @@ discard block |
||
| 96 | 96 | * Liste : Chemin du squelette, durée du cache, contexte |
| 97 | 97 | **/ |
| 98 | 98 | function menu_lang_pour_tous($nom, $default) { |
| 99 | - include_spip('inc/lang'); |
|
| 99 | + include_spip('inc/lang'); |
|
| 100 | 100 | |
| 101 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 102 | - $opt = lang_select($default); # et remplace |
|
| 103 | - if ($GLOBALS['spip_lang'] <> $default) { |
|
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 105 | - if ($opt) { |
|
| 106 | - lang_select(); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 101 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | + if ($GLOBALS['spip_lang'] <> $default) { |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | + if ($opt) { |
|
| 106 | + lang_select(); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - # lien a partir de / |
|
| 112 | - $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&'); |
|
| 111 | + # lien a partir de / |
|
| 112 | + $cible = parametre_url(self(), 'lang', '', '&'); |
|
| 113 | + $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&'); |
|
| 114 | 114 | |
| 115 | - return array( |
|
| 116 | - 'formulaires/menu_lang', |
|
| 117 | - 3600, |
|
| 118 | - array( |
|
| 119 | - 'nom' => $nom, |
|
| 120 | - 'url' => $post, |
|
| 121 | - 'name' => $nom, |
|
| 122 | - 'default' => $default, |
|
| 123 | - ) |
|
| 124 | - ); |
|
| 115 | + return array( |
|
| 116 | + 'formulaires/menu_lang', |
|
| 117 | + 3600, |
|
| 118 | + array( |
|
| 119 | + 'nom' => $nom, |
|
| 120 | + 'url' => $post, |
|
| 121 | + 'name' => $nom, |
|
| 122 | + 'default' => $default, |
|
| 123 | + ) |
|
| 124 | + ); |
|
| 125 | 125 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | include_spip('inc/lang'); |
| 100 | 100 | |
| 101 | 101 | if ($GLOBALS['spip_lang'] <> $default) { |
| 102 | - $opt = lang_select($default); # et remplace |
|
| 102 | + $opt = lang_select($default); # et remplace |
|
| 103 | 103 | if ($GLOBALS['spip_lang'] <> $default) { |
| 104 | - $default = ''; # annule tout choix par defaut |
|
| 104 | + $default = ''; # annule tout choix par defaut |
|
| 105 | 105 | if ($opt) { |
| 106 | 106 | lang_select(); |
| 107 | 107 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | # lien a partir de / |
| 112 | 112 | $cible = parametre_url(self(), 'lang', '', '&'); |
| 113 | - $post = generer_url_action('converser', 'redirect=' . rawurlencode($cible), '&'); |
|
| 113 | + $post = generer_url_action('converser', 'redirect='.rawurlencode($cible), '&'); |
|
| 114 | 114 | |
| 115 | 115 | return array( |
| 116 | 116 | 'formulaires/menu_lang', |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Pile complétée du code compilé |
| 42 | 42 | **/ |
| 43 | 43 | function balise_FORMULAIRE_ECRIRE_AUTEUR($p) { |
| 44 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', array('id_auteur', 'id_article', 'email')); |
|
| 44 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', array('id_auteur', 'id_article', 'email')); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -59,42 +59,42 @@ discard block |
||
| 59 | 59 | * - chaîne vide sinon (erreur ou non affichage). |
| 60 | 60 | */ |
| 61 | 61 | function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) { |
| 62 | - include_spip('inc/filtres'); |
|
| 63 | - // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 64 | - $id = intval($args[1]); |
|
| 65 | - if (!$args[0] and !$id) { |
|
| 66 | - $msg = array( |
|
| 67 | - 'zbug_champ_hors_motif', |
|
| 68 | - array( |
|
| 69 | - 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 70 | - 'motif' => 'AUTEURS/ARTICLES' |
|
| 71 | - ) |
|
| 72 | - ); |
|
| 62 | + include_spip('inc/filtres'); |
|
| 63 | + // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 64 | + $id = intval($args[1]); |
|
| 65 | + if (!$args[0] and !$id) { |
|
| 66 | + $msg = array( |
|
| 67 | + 'zbug_champ_hors_motif', |
|
| 68 | + array( |
|
| 69 | + 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 70 | + 'motif' => 'AUTEURS/ARTICLES' |
|
| 71 | + ) |
|
| 72 | + ); |
|
| 73 | 73 | |
| 74 | - erreur_squelette($msg, $context_compil); |
|
| 74 | + erreur_squelette($msg, $context_compil); |
|
| 75 | 75 | |
| 76 | - return ''; |
|
| 77 | - } |
|
| 78 | - // Si on est dans un contexte article, |
|
| 79 | - // sortir tous les mails des auteurs de l'article |
|
| 80 | - if (!$args[0] and $id) { |
|
| 81 | - $r = ''; |
|
| 82 | - $s = sql_allfetsel('email', |
|
| 83 | - 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | - "A.email != '' AND L.id_objet=$id"); |
|
| 85 | - foreach ($s as $row) { |
|
| 86 | - if (email_valide($row['email'])) { |
|
| 87 | - $r .= ', ' . $row['email']; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - $args[2] = substr($r, 2); |
|
| 91 | - } |
|
| 76 | + return ''; |
|
| 77 | + } |
|
| 78 | + // Si on est dans un contexte article, |
|
| 79 | + // sortir tous les mails des auteurs de l'article |
|
| 80 | + if (!$args[0] and $id) { |
|
| 81 | + $r = ''; |
|
| 82 | + $s = sql_allfetsel('email', |
|
| 83 | + 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | + "A.email != '' AND L.id_objet=$id"); |
|
| 85 | + foreach ($s as $row) { |
|
| 86 | + if (email_valide($row['email'])) { |
|
| 87 | + $r .= ', ' . $row['email']; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + $args[2] = substr($r, 2); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 94 | - if (!$args[2] or !email_valide($args[2])) { |
|
| 95 | - return ''; |
|
| 96 | - } |
|
| 93 | + // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 94 | + if (!$args[2] or !email_valide($args[2])) { |
|
| 95 | + return ''; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - // OK |
|
| 99 | - return $args; |
|
| 98 | + // OK |
|
| 99 | + return $args; |
|
| 100 | 100 | } |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | "A.email != '' AND L.id_objet=$id"); |
| 85 | 85 | foreach ($s as $row) { |
| 86 | 86 | if (email_valide($row['email'])) { |
| 87 | - $r .= ', ' . $row['email']; |
|
| 87 | + $r .= ', '.$row['email']; |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | $args[2] = substr($r, 2); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/abstract_sql'); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * Pile complétée du code compilé |
| 44 | 44 | **/ |
| 45 | 45 | function balise_FORMULAIRE_INSCRIPTION($p) { |
| 46 | - return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', array()); |
|
| 46 | + return calculer_balise_dynamique($p, 'FORMULAIRE_INSCRIPTION', array()); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | * - chaîne vide sinon. |
| 73 | 73 | */ |
| 74 | 74 | function balise_FORMULAIRE_INSCRIPTION_stat($args, $context_compil) { |
| 75 | - list($mode, $id, $retour) = array_pad($args, 3, null); |
|
| 76 | - include_spip('action/inscrire_auteur'); |
|
| 77 | - $mode = tester_statut_inscription($mode, $id); |
|
| 75 | + list($mode, $id, $retour) = array_pad($args, 3, null); |
|
| 76 | + include_spip('action/inscrire_auteur'); |
|
| 77 | + $mode = tester_statut_inscription($mode, $id); |
|
| 78 | 78 | |
| 79 | - return $mode ? array($mode, $id, $retour) : ''; |
|
| 79 | + return $mode ? array($mode, $id, $retour) : ''; |
|
| 80 | 80 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * Pile complétée du code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function balise_MENU_LANG($p) { |
| 40 | - return calculer_balise_dynamique($p, 'MENU_LANG', array('lang')); |
|
| 40 | + return calculer_balise_dynamique($p, 'MENU_LANG', array('lang')); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * Liste (lang) des arguments collectés et fournis. |
| 56 | 56 | */ |
| 57 | 57 | function balise_MENU_LANG_stat($args, $context_compil) { |
| 58 | - if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 58 | + if (strpos($GLOBALS['meta']['langues_multilingue'], ',') === false) { |
|
| 59 | + return ''; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $args; |
|
| 62 | + return $args; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * Liste : Chemin du squelette, durée du cache, contexte |
| 76 | 76 | **/ |
| 77 | 77 | function balise_MENU_LANG_dyn($opt) { |
| 78 | - include_spip('balise/menu_lang_ecrire'); |
|
| 78 | + include_spip('balise/menu_lang_ecrire'); |
|
| 79 | 79 | |
| 80 | - return menu_lang_pour_tous('var_lang', $opt); |
|
| 80 | + return menu_lang_pour_tous('var_lang', $opt); |
|
| 81 | 81 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | // Attributs LDAP correspondants a ceux de SPIP, notamment pour le login |
| 26 | 26 | // ne pas ecraser une definition perso dans mes_options |
| 27 | 27 | if (!isset($GLOBALS['ldap_attributes']) or !is_array($GLOBALS['ldap_attributes'])) { |
| 28 | - $GLOBALS['ldap_attributes'] = array( |
|
| 29 | - 'login' => array('sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'), |
|
| 30 | - 'nom' => "cn", |
|
| 31 | - 'email' => "mail", |
|
| 32 | - 'bio' => "description" |
|
| 33 | - ); |
|
| 28 | + $GLOBALS['ldap_attributes'] = array( |
|
| 29 | + 'login' => array('sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'), |
|
| 30 | + 'nom' => "cn", |
|
| 31 | + 'email' => "mail", |
|
| 32 | + 'bio' => "description" |
|
| 33 | + ); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -56,49 +56,49 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function auth_ldap_dist($login, $pass, $serveur = '', $phpauth = false) { |
| 58 | 58 | |
| 59 | - #spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent")); |
|
| 60 | - |
|
| 61 | - // Utilisateur connu ? |
|
| 62 | - // si http auth, inutile de reauthentifier: cela |
|
| 63 | - // ne marchera pas avec auth http autre que basic. |
|
| 64 | - $checkpass = isset($_SERVER["REMOTE_USER"]) ? false : true; |
|
| 65 | - if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) { |
|
| 66 | - return array(); |
|
| 67 | - } |
|
| 68 | - $credentials_ldap = array('ldap_dn' => $dn, 'ldap_password' => $pass); |
|
| 69 | - |
|
| 70 | - // Si l'utilisateur figure deja dans la base, y recuperer les infos |
|
| 71 | - $r = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 72 | - |
|
| 73 | - if ($r) { |
|
| 74 | - return array_merge($r, $credentials_ldap); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // sinon importer les infos depuis LDAP, |
|
| 78 | - |
|
| 79 | - if ($GLOBALS['meta']["ldap_statut_import"] |
|
| 80 | - and $desc = auth_ldap_retrouver($dn, array(), $serveur) |
|
| 81 | - ) { |
|
| 82 | - // rajouter le statut indique a l'install |
|
| 83 | - $desc['statut'] = $GLOBALS['meta']["ldap_statut_import"]; |
|
| 84 | - $desc['login'] = $login; |
|
| 85 | - $desc['source'] = 'ldap'; |
|
| 86 | - $desc['pass'] = ''; |
|
| 87 | - |
|
| 88 | - $r = sql_insertq('spip_auteurs', $desc, '', $serveur); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - if ($r) { |
|
| 92 | - return array_merge( |
|
| 93 | - $credentials_ldap, |
|
| 94 | - sql_fetsel("*", "spip_auteurs", "id_auteur=" . intval($r), '', '', '', '', $serveur) |
|
| 95 | - ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // sinon echec |
|
| 99 | - spip_log("Creation de l'auteur '$login' impossible"); |
|
| 100 | - |
|
| 101 | - return array(); |
|
| 59 | + #spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent")); |
|
| 60 | + |
|
| 61 | + // Utilisateur connu ? |
|
| 62 | + // si http auth, inutile de reauthentifier: cela |
|
| 63 | + // ne marchera pas avec auth http autre que basic. |
|
| 64 | + $checkpass = isset($_SERVER["REMOTE_USER"]) ? false : true; |
|
| 65 | + if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) { |
|
| 66 | + return array(); |
|
| 67 | + } |
|
| 68 | + $credentials_ldap = array('ldap_dn' => $dn, 'ldap_password' => $pass); |
|
| 69 | + |
|
| 70 | + // Si l'utilisateur figure deja dans la base, y recuperer les infos |
|
| 71 | + $r = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 72 | + |
|
| 73 | + if ($r) { |
|
| 74 | + return array_merge($r, $credentials_ldap); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // sinon importer les infos depuis LDAP, |
|
| 78 | + |
|
| 79 | + if ($GLOBALS['meta']["ldap_statut_import"] |
|
| 80 | + and $desc = auth_ldap_retrouver($dn, array(), $serveur) |
|
| 81 | + ) { |
|
| 82 | + // rajouter le statut indique a l'install |
|
| 83 | + $desc['statut'] = $GLOBALS['meta']["ldap_statut_import"]; |
|
| 84 | + $desc['login'] = $login; |
|
| 85 | + $desc['source'] = 'ldap'; |
|
| 86 | + $desc['pass'] = ''; |
|
| 87 | + |
|
| 88 | + $r = sql_insertq('spip_auteurs', $desc, '', $serveur); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + if ($r) { |
|
| 92 | + return array_merge( |
|
| 93 | + $credentials_ldap, |
|
| 94 | + sql_fetsel("*", "spip_auteurs", "id_auteur=" . intval($r), '', '', '', '', $serveur) |
|
| 95 | + ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // sinon echec |
|
| 99 | + spip_log("Creation de l'auteur '$login' impossible"); |
|
| 100 | + |
|
| 101 | + return array(); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -112,36 +112,36 @@ discard block |
||
| 112 | 112 | * @return array |
| 113 | 113 | */ |
| 114 | 114 | function auth_ldap_connect($serveur = '') { |
| 115 | - include_spip('base/connect_sql'); |
|
| 116 | - static $connexions_ldap = array(); |
|
| 117 | - if (isset($connexions_ldap[$serveur])) { |
|
| 118 | - return $connexions_ldap[$serveur]; |
|
| 119 | - } |
|
| 120 | - $connexion = spip_connect($serveur); |
|
| 121 | - if (!is_array($connexion['ldap'])) { |
|
| 122 | - if ($connexion['authentification']['ldap']) { |
|
| 123 | - $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 124 | - unset($GLOBALS['ldap_link']); |
|
| 125 | - if (is_readable($f)) { |
|
| 126 | - include_once($f); |
|
| 127 | - }; |
|
| 128 | - if (isset($GLOBALS['ldap_link'])) { |
|
| 129 | - $connexion['ldap'] = array( |
|
| 130 | - 'link' => $GLOBALS['ldap_link'], |
|
| 131 | - 'base' => $GLOBALS['ldap_base'] |
|
| 132 | - ); |
|
| 133 | - } else { |
|
| 134 | - spip_log("connection LDAP $serveur mal definie dans $f"); |
|
| 135 | - } |
|
| 136 | - if (isset($GLOBALS['ldap_champs'])) { |
|
| 137 | - $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs']; |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - spip_log("connection LDAP $serveur inconnue"); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - return $connexions_ldap[$serveur] = $connexion['ldap']; |
|
| 115 | + include_spip('base/connect_sql'); |
|
| 116 | + static $connexions_ldap = array(); |
|
| 117 | + if (isset($connexions_ldap[$serveur])) { |
|
| 118 | + return $connexions_ldap[$serveur]; |
|
| 119 | + } |
|
| 120 | + $connexion = spip_connect($serveur); |
|
| 121 | + if (!is_array($connexion['ldap'])) { |
|
| 122 | + if ($connexion['authentification']['ldap']) { |
|
| 123 | + $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 124 | + unset($GLOBALS['ldap_link']); |
|
| 125 | + if (is_readable($f)) { |
|
| 126 | + include_once($f); |
|
| 127 | + }; |
|
| 128 | + if (isset($GLOBALS['ldap_link'])) { |
|
| 129 | + $connexion['ldap'] = array( |
|
| 130 | + 'link' => $GLOBALS['ldap_link'], |
|
| 131 | + 'base' => $GLOBALS['ldap_base'] |
|
| 132 | + ); |
|
| 133 | + } else { |
|
| 134 | + spip_log("connection LDAP $serveur mal definie dans $f"); |
|
| 135 | + } |
|
| 136 | + if (isset($GLOBALS['ldap_champs'])) { |
|
| 137 | + $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs']; |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + spip_log("connection LDAP $serveur inconnue"); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + return $connexions_ldap[$serveur] = $connexion['ldap']; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -155,52 +155,52 @@ discard block |
||
| 155 | 155 | * Le login trouvé ou chaine vide si non trouvé |
| 156 | 156 | */ |
| 157 | 157 | function auth_ldap_search($login, $pass, $checkpass = true, $serveur = '') { |
| 158 | - // Securite anti-injection et contre un serveur LDAP laxiste |
|
| 159 | - $login_search = preg_replace("/[^-@._\s\d\w]/", "", $login); |
|
| 160 | - if (!strlen($login_search) or ($checkpass and !strlen($pass))) { |
|
| 161 | - return ''; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // verifier la connexion |
|
| 165 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 166 | - return ''; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - $ldap_link = isset($ldap['link']) ? $ldap['link'] : null; |
|
| 170 | - $ldap_base = isset($ldap['base']) ? $ldap['base'] : null; |
|
| 171 | - $desc = isset($ldap['attributes']) && $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ; |
|
| 172 | - |
|
| 173 | - $logins = is_array($desc['login']) ? $desc['login'] : array($desc['login']); |
|
| 174 | - |
|
| 175 | - // Tenter une recherche pour essayer de retrouver le DN |
|
| 176 | - foreach ($logins as $att) { |
|
| 177 | - $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", array("dn")); |
|
| 178 | - $info = @ldap_get_entries($ldap_link, $result); |
|
| 179 | - // Ne pas accepter les resultats si plus d'une entree |
|
| 180 | - // (on veut un attribut unique) |
|
| 181 | - |
|
| 182 | - if (is_array($info) and $info['count'] == 1) { |
|
| 183 | - $dn = $info[0]['dn']; |
|
| 184 | - if (!$checkpass) { |
|
| 185 | - return $dn; |
|
| 186 | - } |
|
| 187 | - if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 188 | - return $dn; |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - if ($checkpass and !isset($dn)) { |
|
| 194 | - // Si echec, essayer de deviner le DN |
|
| 195 | - foreach ($logins as $att) { |
|
| 196 | - $dn = "$att=$login_search, $ldap_base"; |
|
| 197 | - if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 198 | - return "$att=$login_search, $ldap_base"; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - return ''; |
|
| 158 | + // Securite anti-injection et contre un serveur LDAP laxiste |
|
| 159 | + $login_search = preg_replace("/[^-@._\s\d\w]/", "", $login); |
|
| 160 | + if (!strlen($login_search) or ($checkpass and !strlen($pass))) { |
|
| 161 | + return ''; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // verifier la connexion |
|
| 165 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 166 | + return ''; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + $ldap_link = isset($ldap['link']) ? $ldap['link'] : null; |
|
| 170 | + $ldap_base = isset($ldap['base']) ? $ldap['base'] : null; |
|
| 171 | + $desc = isset($ldap['attributes']) && $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ; |
|
| 172 | + |
|
| 173 | + $logins = is_array($desc['login']) ? $desc['login'] : array($desc['login']); |
|
| 174 | + |
|
| 175 | + // Tenter une recherche pour essayer de retrouver le DN |
|
| 176 | + foreach ($logins as $att) { |
|
| 177 | + $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", array("dn")); |
|
| 178 | + $info = @ldap_get_entries($ldap_link, $result); |
|
| 179 | + // Ne pas accepter les resultats si plus d'une entree |
|
| 180 | + // (on veut un attribut unique) |
|
| 181 | + |
|
| 182 | + if (is_array($info) and $info['count'] == 1) { |
|
| 183 | + $dn = $info[0]['dn']; |
|
| 184 | + if (!$checkpass) { |
|
| 185 | + return $dn; |
|
| 186 | + } |
|
| 187 | + if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 188 | + return $dn; |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + if ($checkpass and !isset($dn)) { |
|
| 194 | + // Si echec, essayer de deviner le DN |
|
| 195 | + foreach ($logins as $att) { |
|
| 196 | + $dn = "$att=$login_search, $ldap_base"; |
|
| 197 | + if (@ldap_bind($ldap_link, $dn, $pass)) { |
|
| 198 | + return "$att=$login_search, $ldap_base"; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + return ''; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -212,40 +212,40 @@ discard block |
||
| 212 | 212 | * @return array |
| 213 | 213 | */ |
| 214 | 214 | function auth_ldap_retrouver($dn, $desc = array(), $serveur = '') { |
| 215 | - // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP |
|
| 215 | + // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP |
|
| 216 | 216 | |
| 217 | - if (!$ldap = spip_connect_ldap($serveur)) { |
|
| 218 | - spip_log("ldap $serveur injoignable"); |
|
| 217 | + if (!$ldap = spip_connect_ldap($serveur)) { |
|
| 218 | + spip_log("ldap $serveur injoignable"); |
|
| 219 | 219 | |
| 220 | - return array(); |
|
| 221 | - } |
|
| 220 | + return array(); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - $ldap_link = $ldap['link']; |
|
| 224 | - if (!$desc) { |
|
| 225 | - $desc = $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes']; |
|
| 226 | - unset($desc['login']); |
|
| 227 | - } |
|
| 228 | - $result = @ldap_read($ldap_link, $dn, "objectClass=*", array_values($desc)); |
|
| 223 | + $ldap_link = $ldap['link']; |
|
| 224 | + if (!$desc) { |
|
| 225 | + $desc = $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes']; |
|
| 226 | + unset($desc['login']); |
|
| 227 | + } |
|
| 228 | + $result = @ldap_read($ldap_link, $dn, "objectClass=*", array_values($desc)); |
|
| 229 | 229 | |
| 230 | - if (!$result) { |
|
| 231 | - return array(); |
|
| 232 | - } |
|
| 230 | + if (!$result) { |
|
| 231 | + return array(); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - // Recuperer les donnees du premier (unique?) compte de l'auteur |
|
| 235 | - $val = @ldap_get_entries($ldap_link, $result); |
|
| 236 | - if (!is_array($val) or !is_array($val[0])) { |
|
| 237 | - return array(); |
|
| 238 | - } |
|
| 239 | - $val = $val[0]; |
|
| 234 | + // Recuperer les donnees du premier (unique?) compte de l'auteur |
|
| 235 | + $val = @ldap_get_entries($ldap_link, $result); |
|
| 236 | + if (!is_array($val) or !is_array($val[0])) { |
|
| 237 | + return array(); |
|
| 238 | + } |
|
| 239 | + $val = $val[0]; |
|
| 240 | 240 | |
| 241 | - // Convertir depuis UTF-8 (jeu de caracteres par defaut) |
|
| 242 | - include_spip('inc/charsets'); |
|
| 241 | + // Convertir depuis UTF-8 (jeu de caracteres par defaut) |
|
| 242 | + include_spip('inc/charsets'); |
|
| 243 | 243 | |
| 244 | - foreach ($desc as $k => $v) { |
|
| 245 | - $desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8'); |
|
| 246 | - } |
|
| 244 | + foreach ($desc as $k => $v) { |
|
| 245 | + $desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8'); |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - return $desc; |
|
| 248 | + return $desc; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @return string |
| 258 | 258 | */ |
| 259 | 259 | function auth_ldap_retrouver_login($login, $serveur = '') { |
| 260 | - return auth_ldap_search($login, '', false, $serveur) ? $login : ''; |
|
| 260 | + return auth_ldap_search($login, '', false, $serveur) ? $login : ''; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -277,9 +277,9 @@ discard block |
||
| 277 | 277 | * Message d'erreur si login non valide, chaîne vide sinon |
| 278 | 278 | */ |
| 279 | 279 | function auth_ldap_verifier_pass($login, $new_pass, $id_auteur = 0, $serveur = '') { |
| 280 | - include_spip('auth/spip'); |
|
| 280 | + include_spip('auth/spip'); |
|
| 281 | 281 | |
| 282 | - return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur); |
|
| 282 | + return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * ``` |
| 301 | 301 | */ |
| 302 | 302 | function auth_ldap_autoriser_modifier_pass($serveur = '') { |
| 303 | - return true; |
|
| 303 | + return true; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -318,23 +318,23 @@ discard block |
||
| 318 | 318 | * Informe du succès ou de l'echec du changement du mot de passe |
| 319 | 319 | */ |
| 320 | 320 | function auth_ldap_modifier_pass($login, $new_pass, $id_auteur, $serveur = '') { |
| 321 | - if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 322 | - return false; |
|
| 323 | - } |
|
| 324 | - if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 325 | - return ''; |
|
| 326 | - } |
|
| 327 | - $link = $ldap['link']; |
|
| 328 | - include_spip("inc/session"); |
|
| 329 | - $dn = session_get('ldap_dn'); |
|
| 330 | - if ('' == $dn) { |
|
| 331 | - return false; |
|
| 332 | - } |
|
| 333 | - if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
|
| 334 | - return false; |
|
| 335 | - } |
|
| 336 | - $encoded_pass = "{MD5}" . base64_encode(pack("H*", md5($new_pass))); |
|
| 337 | - $success = ldap_mod_replace($link, $dn, array('userPassword' => $encoded_pass)); |
|
| 338 | - |
|
| 339 | - return $success; |
|
| 321 | + if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') { |
|
| 322 | + return false; |
|
| 323 | + } |
|
| 324 | + if (!$ldap = auth_ldap_connect($serveur)) { |
|
| 325 | + return ''; |
|
| 326 | + } |
|
| 327 | + $link = $ldap['link']; |
|
| 328 | + include_spip("inc/session"); |
|
| 329 | + $dn = session_get('ldap_dn'); |
|
| 330 | + if ('' == $dn) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 333 | + if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
|
| 334 | + return false; |
|
| 335 | + } |
|
| 336 | + $encoded_pass = "{MD5}" . base64_encode(pack("H*", md5($new_pass))); |
|
| 337 | + $success = ldap_mod_replace($link, $dn, array('userPassword' => $encoded_pass)); |
|
| 338 | + |
|
| 339 | + return $success; |
|
| 340 | 340 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $credentials_ldap = array('ldap_dn' => $dn, 'ldap_password' => $pass); |
| 69 | 69 | |
| 70 | 70 | // Si l'utilisateur figure deja dans la base, y recuperer les infos |
| 71 | - $r = sql_fetsel("*", "spip_auteurs", "login=" . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur); |
|
| 71 | + $r = sql_fetsel("*", "spip_auteurs", "login=".sql_quote($login)." AND source='ldap'", '', '', '', '', $serveur); |
|
| 72 | 72 | |
| 73 | 73 | if ($r) { |
| 74 | 74 | return array_merge($r, $credentials_ldap); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | if ($r) { |
| 92 | 92 | return array_merge( |
| 93 | 93 | $credentials_ldap, |
| 94 | - sql_fetsel("*", "spip_auteurs", "id_auteur=" . intval($r), '', '', '', '', $serveur) |
|
| 94 | + sql_fetsel("*", "spip_auteurs", "id_auteur=".intval($r), '', '', '', '', $serveur) |
|
| 95 | 95 | ); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $connexion = spip_connect($serveur); |
| 121 | 121 | if (!is_array($connexion['ldap'])) { |
| 122 | 122 | if ($connexion['authentification']['ldap']) { |
| 123 | - $f = _DIR_CONNECT . $connexion['authentification']['ldap']; |
|
| 123 | + $f = _DIR_CONNECT.$connexion['authentification']['ldap']; |
|
| 124 | 124 | unset($GLOBALS['ldap_link']); |
| 125 | 125 | if (is_readable($f)) { |
| 126 | 126 | include_once($f); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | $ldap_link = isset($ldap['link']) ? $ldap['link'] : null; |
| 170 | 170 | $ldap_base = isset($ldap['base']) ? $ldap['base'] : null; |
| 171 | - $desc = isset($ldap['attributes']) && $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes'] ; |
|
| 171 | + $desc = isset($ldap['attributes']) && $ldap['attributes'] ? $ldap['attributes'] : $GLOBALS['ldap_attributes']; |
|
| 172 | 172 | |
| 173 | 173 | $logins = is_array($desc['login']) ? $desc['login'] : array($desc['login']); |
| 174 | 174 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | if (!ldap_bind($link, $dn, session_get('ldap_password'))) { |
| 334 | 334 | return false; |
| 335 | 335 | } |
| 336 | - $encoded_pass = "{MD5}" . base64_encode(pack("H*", md5($new_pass))); |
|
| 336 | + $encoded_pass = "{MD5}".base64_encode(pack("H*", md5($new_pass))); |
|
| 337 | 337 | $success = ldap_mod_replace($link, $dn, array('userPassword' => $encoded_pass)); |
| 338 | 338 | |
| 339 | 339 | return $success; |