@@ -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 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
@@ -21,26 +21,26 @@ discard block |
||
| 21 | 21 | * @param array $arbre |
| 22 | 22 | */ |
| 23 | 23 | function plugins_extraire_pipelines_dist(&$arbre) { |
| 24 | - $pipeline = array(); |
|
| 25 | - if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 26 | - foreach ($pipes as $tag => $p) { |
|
| 27 | - if (!is_array($p[0])) { |
|
| 28 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 29 | - $pipeline[] = $att; |
|
| 30 | - } else { |
|
| 31 | - foreach ($p as $pipe) { |
|
| 32 | - $att = array(); |
|
| 33 | - if (is_array($pipe)) { |
|
| 34 | - foreach ($pipe as $k => $t) { |
|
| 35 | - $att[$k] = trim(end($t)); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - $pipeline[] = $att; |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - unset($arbre[$tag]); |
|
| 43 | - } |
|
| 24 | + $pipeline = array(); |
|
| 25 | + if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) { |
|
| 26 | + foreach ($pipes as $tag => $p) { |
|
| 27 | + if (!is_array($p[0])) { |
|
| 28 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 29 | + $pipeline[] = $att; |
|
| 30 | + } else { |
|
| 31 | + foreach ($p as $pipe) { |
|
| 32 | + $att = array(); |
|
| 33 | + if (is_array($pipe)) { |
|
| 34 | + foreach ($pipe as $k => $t) { |
|
| 35 | + $att[$k] = trim(end($t)); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + $pipeline[] = $att; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + unset($arbre[$tag]); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - return $pipeline; |
|
| 45 | + return $pipeline; |
|
| 46 | 46 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -21,30 +21,30 @@ discard block |
||
| 21 | 21 | * @return <type> |
| 22 | 22 | */ |
| 23 | 23 | function plugins_extraire_boutons_dist($arbre) { |
| 24 | - $ret = array('bouton' => array(), 'onglet' => array()); |
|
| 25 | - // recuperer les boutons et onglets si necessaire |
|
| 26 | - spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons); |
|
| 27 | - if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | - $ret['bouton'] = array(); |
|
| 29 | - $ret['onglet'] = array(); |
|
| 30 | - foreach ($les_boutons as $bouton => $val) { |
|
| 31 | - $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | - $type = reset($bouton); |
|
| 33 | - $bouton = end($bouton); |
|
| 34 | - if (isset($bouton['id'])) { |
|
| 35 | - $id = $bouton['id']; |
|
| 36 | - $val = reset($val); |
|
| 37 | - if (is_array($val)) { |
|
| 38 | - $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : ''; |
|
| 39 | - $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : ''; |
|
| 40 | - $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | - $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 42 | - $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 43 | - $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 24 | + $ret = array('bouton' => array(), 'onglet' => array()); |
|
| 25 | + // recuperer les boutons et onglets si necessaire |
|
| 26 | + spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons); |
|
| 27 | + if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | + $ret['bouton'] = array(); |
|
| 29 | + $ret['onglet'] = array(); |
|
| 30 | + foreach ($les_boutons as $bouton => $val) { |
|
| 31 | + $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | + $type = reset($bouton); |
|
| 33 | + $bouton = end($bouton); |
|
| 34 | + if (isset($bouton['id'])) { |
|
| 35 | + $id = $bouton['id']; |
|
| 36 | + $val = reset($val); |
|
| 37 | + if (is_array($val)) { |
|
| 38 | + $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : ''; |
|
| 39 | + $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : ''; |
|
| 40 | + $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | + $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 42 | + $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 43 | + $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $ret; |
|
| 49 | + return $ret; |
|
| 50 | 50 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | define('_REGEXP_DOCTYPE', |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
| 34 | 34 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 35 | 35 | define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
| 36 | - _SUB_REGEXP_SYMBOL . |
|
| 37 | - '+;?)\s+(' . |
|
| 38 | - _REGEXP_TYPE_XML . |
|
| 39 | - ')?\s*(' . |
|
| 40 | - "('([^']*)')" . |
|
| 41 | - '|("([^"]*)")' . |
|
| 42 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 43 | - ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 36 | + _SUB_REGEXP_SYMBOL . |
|
| 37 | + '+;?)\s+(' . |
|
| 38 | + _REGEXP_TYPE_XML . |
|
| 39 | + ')?\s*(' . |
|
| 40 | + "('([^']*)')" . |
|
| 41 | + '|("([^"]*)")' . |
|
| 42 | + '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 43 | + ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 44 | 44 | |
| 45 | 45 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
| 46 | 46 | |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | * Document Type Compilation |
| 51 | 51 | **/ |
| 52 | 52 | class DTC { |
| 53 | - public $macros = array(); |
|
| 54 | - public $elements = array(); |
|
| 55 | - public $peres = array(); |
|
| 56 | - public $attributs = array(); |
|
| 57 | - public $entites = array(); |
|
| 58 | - public $regles = array(); |
|
| 59 | - public $pcdata = array(); |
|
| 53 | + public $macros = array(); |
|
| 54 | + public $elements = array(); |
|
| 55 | + public $peres = array(); |
|
| 56 | + public $attributs = array(); |
|
| 57 | + public $entites = array(); |
|
| 58 | + public $regles = array(); |
|
| 59 | + public $pcdata = array(); |
|
| 60 | 60 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -33,64 +33,64 @@ discard block |
||
| 33 | 33 | // Cas d'une page contenant du PHP : |
| 34 | 34 | if (empty($page['process_ins']) or $page['process_ins'] != 'html') { |
| 35 | 35 | |
| 36 | - include_spip('inc/lang'); |
|
| 36 | + include_spip('inc/lang'); |
|
| 37 | 37 | |
| 38 | - // restaurer l'etat des notes avant calcul |
|
| 39 | - if (isset($page['notes']) |
|
| 40 | - and $page['notes'] |
|
| 41 | - and $notes = charger_fonction("notes", "inc", true) |
|
| 42 | - ) { |
|
| 43 | - $notes($page['notes'], 'restaurer_etat'); |
|
| 44 | - } |
|
| 45 | - ob_start(); |
|
| 46 | - if (strpos($page['texte'], '?xml') !== false) { |
|
| 47 | - $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']); |
|
| 48 | - } |
|
| 38 | + // restaurer l'etat des notes avant calcul |
|
| 39 | + if (isset($page['notes']) |
|
| 40 | + and $page['notes'] |
|
| 41 | + and $notes = charger_fonction("notes", "inc", true) |
|
| 42 | + ) { |
|
| 43 | + $notes($page['notes'], 'restaurer_etat'); |
|
| 44 | + } |
|
| 45 | + ob_start(); |
|
| 46 | + if (strpos($page['texte'], '?xml') !== false) { |
|
| 47 | + $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - try { |
|
| 51 | - $res = eval('?' . '>' . $page['texte']); |
|
| 52 | - // error catching 5.2<=PHP<7 |
|
| 53 | - if ($res === false |
|
| 54 | - and function_exists('error_get_last') |
|
| 55 | - and ($erreur = error_get_last()) ) { |
|
| 56 | - $code = $page['texte']; |
|
| 57 | - $GLOBALS['numero_ligne_php'] = 1; |
|
| 58 | - if (!function_exists('numerote_ligne_php')){ |
|
| 59 | - function numerote_ligne_php($match){ |
|
| 60 | - $GLOBALS['numero_ligne_php']++; |
|
| 61 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 65 | - $code = trim(highlight_string($code,true)); |
|
| 66 | - erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 67 | - $page['texte'] = "<!-- Erreur -->"; |
|
| 68 | - } |
|
| 69 | - else { |
|
| 70 | - $page['texte'] = ob_get_contents(); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - catch (Exception $e){ |
|
| 74 | - $code = $page['texte']; |
|
| 75 | - $GLOBALS['numero_ligne_php'] = 1; |
|
| 76 | - if (!function_exists('numerote_ligne_php')){ |
|
| 77 | - function numerote_ligne_php($match){ |
|
| 78 | - $GLOBALS['numero_ligne_php']++; |
|
| 79 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 83 | - $code = trim(highlight_string($code,true)); |
|
| 84 | - erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 85 | - $page['texte'] = "<!-- Erreur -->"; |
|
| 86 | - } |
|
| 87 | - ob_end_clean(); |
|
| 50 | + try { |
|
| 51 | + $res = eval('?' . '>' . $page['texte']); |
|
| 52 | + // error catching 5.2<=PHP<7 |
|
| 53 | + if ($res === false |
|
| 54 | + and function_exists('error_get_last') |
|
| 55 | + and ($erreur = error_get_last()) ) { |
|
| 56 | + $code = $page['texte']; |
|
| 57 | + $GLOBALS['numero_ligne_php'] = 1; |
|
| 58 | + if (!function_exists('numerote_ligne_php')){ |
|
| 59 | + function numerote_ligne_php($match){ |
|
| 60 | + $GLOBALS['numero_ligne_php']++; |
|
| 61 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 65 | + $code = trim(highlight_string($code,true)); |
|
| 66 | + erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 67 | + $page['texte'] = "<!-- Erreur -->"; |
|
| 68 | + } |
|
| 69 | + else { |
|
| 70 | + $page['texte'] = ob_get_contents(); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + catch (Exception $e){ |
|
| 74 | + $code = $page['texte']; |
|
| 75 | + $GLOBALS['numero_ligne_php'] = 1; |
|
| 76 | + if (!function_exists('numerote_ligne_php')){ |
|
| 77 | + function numerote_ligne_php($match){ |
|
| 78 | + $GLOBALS['numero_ligne_php']++; |
|
| 79 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 83 | + $code = trim(highlight_string($code,true)); |
|
| 84 | + erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 85 | + $page['texte'] = "<!-- Erreur -->"; |
|
| 86 | + } |
|
| 87 | + ob_end_clean(); |
|
| 88 | 88 | |
| 89 | - $page['process_ins'] = 'html'; |
|
| 89 | + $page['process_ins'] = 'html'; |
|
| 90 | 90 | |
| 91 | - if (strpos($page['texte'], '?xml') !== false) { |
|
| 92 | - $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']); |
|
| 93 | - } |
|
| 91 | + if (strpos($page['texte'], '?xml') !== false) { |
|
| 92 | + $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']); |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | page_base_href($page['texte']); |
@@ -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 | /** |
@@ -34,32 +34,32 @@ discard block |
||
| 34 | 34 | * Contenu HTML, avec boutons d'administrations et sa CSS |
| 35 | 35 | **/ |
| 36 | 36 | function affiche_boutons_admin($contenu) { |
| 37 | - include_spip('inc/filtres'); |
|
| 37 | + include_spip('inc/filtres'); |
|
| 38 | 38 | |
| 39 | - // Inserer le css d'admin |
|
| 40 | - $css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css'))) |
|
| 41 | - . "' type='text/css' />\n"; |
|
| 42 | - if ($f = find_in_path('spip_admin_perso.css')) { |
|
| 43 | - $css .= "<link rel='stylesheet' href='" |
|
| 44 | - . url_absolue(direction_css($f)) . "' type='text/css' />\n"; |
|
| 45 | - } |
|
| 39 | + // Inserer le css d'admin |
|
| 40 | + $css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css'))) |
|
| 41 | + . "' type='text/css' />\n"; |
|
| 42 | + if ($f = find_in_path('spip_admin_perso.css')) { |
|
| 43 | + $css .= "<link rel='stylesheet' href='" |
|
| 44 | + . url_absolue(direction_css($f)) . "' type='text/css' />\n"; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - ($pos = stripos($contenu, '</head>')) |
|
| 48 | - || ($pos = stripos($contenu, '<body>')) |
|
| 49 | - || ($pos = 0); |
|
| 50 | - $contenu = substr_replace($contenu, $css, $pos, 0); |
|
| 47 | + ($pos = stripos($contenu, '</head>')) |
|
| 48 | + || ($pos = stripos($contenu, '<body>')) |
|
| 49 | + || ($pos = 0); |
|
| 50 | + $contenu = substr_replace($contenu, $css, $pos, 0); |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - // Inserer la balise #FORMULAIRE_ADMIN, en float |
|
| 54 | - $boutons_admin = inclure_balise_dynamique( |
|
| 55 | - balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'), |
|
| 56 | - false); |
|
| 53 | + // Inserer la balise #FORMULAIRE_ADMIN, en float |
|
| 54 | + $boutons_admin = inclure_balise_dynamique( |
|
| 55 | + balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'), |
|
| 56 | + false); |
|
| 57 | 57 | |
| 58 | - ($pos = strripos($contenu, '</body>')) |
|
| 59 | - || ($pos = strripos($contenu, '</html>')) |
|
| 60 | - || ($pos = strlen($contenu)); |
|
| 61 | - $contenu = substr_replace($contenu, $boutons_admin, $pos, 0); |
|
| 58 | + ($pos = strripos($contenu, '</body>')) |
|
| 59 | + || ($pos = strripos($contenu, '</html>')) |
|
| 60 | + || ($pos = strlen($contenu)); |
|
| 61 | + $contenu = substr_replace($contenu, $boutons_admin, $pos, 0); |
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | - return $contenu; |
|
| 64 | + return $contenu; |
|
| 65 | 65 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @package SPIP\Core\Public\Styliser |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined("_ECRIRE_INC_VERSION")) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -29,181 +29,181 @@ discard block |
||
| 29 | 29 | * @return array Données modifiées du pipeline |
| 30 | 30 | */ |
| 31 | 31 | function public_styliser_par_z_dist($flux) { |
| 32 | - static $prefix_path = null; |
|
| 33 | - static $prefix_length; |
|
| 34 | - static $z_blocs; |
|
| 35 | - static $apl_constant; |
|
| 36 | - static $page; |
|
| 37 | - static $disponible = array(); |
|
| 38 | - static $echafauder; |
|
| 39 | - static $prepend = ""; |
|
| 40 | - |
|
| 41 | - if (!isset($prefix_path)) { |
|
| 42 | - $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | - if (test_espace_prive()) { |
|
| 44 | - $prefix_path = "prive/squelettes/"; |
|
| 45 | - $prefix_length = strlen($prefix_path); |
|
| 46 | - $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | - $page = 'exec'; |
|
| 48 | - $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | - define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | - } else { |
|
| 51 | - $prefix_path = ""; |
|
| 52 | - $prefix_length = 0; |
|
| 53 | - $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | - $page = _SPIP_PAGE; |
|
| 55 | - $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | - define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST, |
|
| 57 | - '/') : '')); |
|
| 58 | - } |
|
| 59 | - $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ""); |
|
| 60 | - } |
|
| 61 | - $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 62 | - |
|
| 63 | - $fond = $flux['args']['fond']; |
|
| 64 | - |
|
| 65 | - if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 66 | - $fond = substr($fond, $prefix_length); |
|
| 67 | - $squelette = $flux['data']; |
|
| 68 | - $ext = $flux['args']['ext']; |
|
| 69 | - // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 70 | - if (defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 71 | - and $dir = explode('/', $fond) |
|
| 72 | - and count($dir) == 2 // pas un sous repertoire |
|
| 73 | - and $dir = reset($dir) |
|
| 74 | - and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 75 | - and defined($apl_constant) |
|
| 76 | - and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 77 | - and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 78 | - ) { |
|
| 79 | - $flux['data'] = $pipe; |
|
| 80 | - |
|
| 81 | - return $flux; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 85 | - if ($squelette and !z_fond_valide($squelette)) { |
|
| 86 | - $squelette = ""; |
|
| 87 | - $echafauder = ""; |
|
| 88 | - } |
|
| 89 | - if ($prepend) { |
|
| 90 | - $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 91 | - if ($squelette) { |
|
| 92 | - $flux['data'] = $squelette; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // gerer les squelettes non trouves |
|
| 97 | - // -> router vers les /dist.html |
|
| 98 | - // ou scaffolding ou page automatique les contenus |
|
| 99 | - if (!$squelette) { |
|
| 100 | - |
|
| 101 | - // si on est sur un ?page=XX non trouve |
|
| 102 | - if ((isset($flux['args']['contexte'][$page]) |
|
| 103 | - and $flux['args']['contexte'][$page] == $fond) |
|
| 104 | - or (isset($flux['args']['contexte']['type-page']) |
|
| 105 | - and $flux['args']['contexte']['type-page'] == $fond) |
|
| 106 | - or ($fond == 'sommaire' |
|
| 107 | - and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 108 | - ) { |
|
| 109 | - |
|
| 110 | - // si on est sur un ?page=XX non trouve |
|
| 111 | - // se brancher sur contenu/xx si il existe |
|
| 112 | - // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 113 | - if (!isset($disponible[$fond])) { |
|
| 114 | - $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - if ($disponible[$fond]) { |
|
| 118 | - $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // echafaudage : |
|
| 123 | - // si c'est un fond de contenu d'un objet en base |
|
| 124 | - // generer un fond automatique a la volee pour les webmestres |
|
| 125 | - elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 126 | - $type = substr($fond, strlen($z_contenu) + 1); |
|
| 127 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 128 | - $type = $flux['args']['contexte'][$page]; |
|
| 129 | - } |
|
| 130 | - if (!isset($disponible[$type])) { |
|
| 131 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 132 | - } |
|
| 133 | - if (is_string($disponible[$type])) { |
|
| 134 | - $flux['data'] = $disponible[$type]; |
|
| 135 | - } elseif ($echafauder |
|
| 136 | - and include_spip('inc/autoriser') |
|
| 137 | - and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 138 | - and autoriser('echafauder', $type) |
|
| 139 | - and $is = $disponible[$type] |
|
| 140 | - and is_array($is) |
|
| 141 | - ) { |
|
| 142 | - $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 143 | - } else { |
|
| 144 | - $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext, |
|
| 145 | - $echafauder)); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 150 | - // et si il y a bien un contenu correspondant ou echafaudable |
|
| 151 | - // se rabbatre sur le dist.html du bloc concerne |
|
| 152 | - else { |
|
| 153 | - if ($dir = explode('/', $fond) |
|
| 154 | - and $dir = reset($dir) |
|
| 155 | - and $dir !== $z_contenu |
|
| 156 | - and in_array($dir, $z_blocs) |
|
| 157 | - ) { |
|
| 158 | - $type = substr($fond, strlen("$dir/")); |
|
| 159 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 160 | - $type = $flux['args']['contexte'][$page]; |
|
| 161 | - } |
|
| 162 | - if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 163 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 164 | - } |
|
| 165 | - if ($type == 'page' or $disponible[$type]) { |
|
| 166 | - $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - $squelette = $flux['data']; |
|
| 171 | - } |
|
| 172 | - // layout specifiques par type et compositions : |
|
| 173 | - // body-article.html |
|
| 174 | - // body-sommaire.html |
|
| 175 | - // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 176 | - // meme dossier que body.html |
|
| 177 | - if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 178 | - if (isset($flux['args']['contexte']['type-page']) |
|
| 179 | - and ( |
|
| 180 | - (isset($flux['args']['contexte']['composition']) |
|
| 181 | - and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 182 | - or |
|
| 183 | - file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 184 | - ) |
|
| 185 | - ) { |
|
| 186 | - $flux['data'] = $f; |
|
| 187 | - } |
|
| 188 | - } elseif ($fond == 'structure' |
|
| 189 | - and z_sanitize_var_zajax() |
|
| 190 | - and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 191 | - ) { |
|
| 192 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 193 | - } // chercher le fond correspondant a la composition |
|
| 194 | - elseif (isset($flux['args']['contexte']['composition']) |
|
| 195 | - and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 196 | - and $dir = substr($fond, $prefix_length) |
|
| 197 | - and $dir = explode('/', $dir) |
|
| 198 | - and $dir = reset($dir) |
|
| 199 | - and in_array($dir, $z_blocs) |
|
| 200 | - and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 201 | - ) { |
|
| 202 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - return $flux; |
|
| 32 | + static $prefix_path = null; |
|
| 33 | + static $prefix_length; |
|
| 34 | + static $z_blocs; |
|
| 35 | + static $apl_constant; |
|
| 36 | + static $page; |
|
| 37 | + static $disponible = array(); |
|
| 38 | + static $echafauder; |
|
| 39 | + static $prepend = ""; |
|
| 40 | + |
|
| 41 | + if (!isset($prefix_path)) { |
|
| 42 | + $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | + if (test_espace_prive()) { |
|
| 44 | + $prefix_path = "prive/squelettes/"; |
|
| 45 | + $prefix_length = strlen($prefix_path); |
|
| 46 | + $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | + $page = 'exec'; |
|
| 48 | + $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | + define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | + } else { |
|
| 51 | + $prefix_path = ""; |
|
| 52 | + $prefix_length = 0; |
|
| 53 | + $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | + $page = _SPIP_PAGE; |
|
| 55 | + $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | + define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST, |
|
| 57 | + '/') : '')); |
|
| 58 | + } |
|
| 59 | + $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ""); |
|
| 60 | + } |
|
| 61 | + $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 62 | + |
|
| 63 | + $fond = $flux['args']['fond']; |
|
| 64 | + |
|
| 65 | + if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 66 | + $fond = substr($fond, $prefix_length); |
|
| 67 | + $squelette = $flux['data']; |
|
| 68 | + $ext = $flux['args']['ext']; |
|
| 69 | + // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 70 | + if (defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 71 | + and $dir = explode('/', $fond) |
|
| 72 | + and count($dir) == 2 // pas un sous repertoire |
|
| 73 | + and $dir = reset($dir) |
|
| 74 | + and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 75 | + and defined($apl_constant) |
|
| 76 | + and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 77 | + and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 78 | + ) { |
|
| 79 | + $flux['data'] = $pipe; |
|
| 80 | + |
|
| 81 | + return $flux; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 85 | + if ($squelette and !z_fond_valide($squelette)) { |
|
| 86 | + $squelette = ""; |
|
| 87 | + $echafauder = ""; |
|
| 88 | + } |
|
| 89 | + if ($prepend) { |
|
| 90 | + $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 91 | + if ($squelette) { |
|
| 92 | + $flux['data'] = $squelette; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // gerer les squelettes non trouves |
|
| 97 | + // -> router vers les /dist.html |
|
| 98 | + // ou scaffolding ou page automatique les contenus |
|
| 99 | + if (!$squelette) { |
|
| 100 | + |
|
| 101 | + // si on est sur un ?page=XX non trouve |
|
| 102 | + if ((isset($flux['args']['contexte'][$page]) |
|
| 103 | + and $flux['args']['contexte'][$page] == $fond) |
|
| 104 | + or (isset($flux['args']['contexte']['type-page']) |
|
| 105 | + and $flux['args']['contexte']['type-page'] == $fond) |
|
| 106 | + or ($fond == 'sommaire' |
|
| 107 | + and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 108 | + ) { |
|
| 109 | + |
|
| 110 | + // si on est sur un ?page=XX non trouve |
|
| 111 | + // se brancher sur contenu/xx si il existe |
|
| 112 | + // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 113 | + if (!isset($disponible[$fond])) { |
|
| 114 | + $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + if ($disponible[$fond]) { |
|
| 118 | + $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // echafaudage : |
|
| 123 | + // si c'est un fond de contenu d'un objet en base |
|
| 124 | + // generer un fond automatique a la volee pour les webmestres |
|
| 125 | + elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 126 | + $type = substr($fond, strlen($z_contenu) + 1); |
|
| 127 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 128 | + $type = $flux['args']['contexte'][$page]; |
|
| 129 | + } |
|
| 130 | + if (!isset($disponible[$type])) { |
|
| 131 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 132 | + } |
|
| 133 | + if (is_string($disponible[$type])) { |
|
| 134 | + $flux['data'] = $disponible[$type]; |
|
| 135 | + } elseif ($echafauder |
|
| 136 | + and include_spip('inc/autoriser') |
|
| 137 | + and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 138 | + and autoriser('echafauder', $type) |
|
| 139 | + and $is = $disponible[$type] |
|
| 140 | + and is_array($is) |
|
| 141 | + ) { |
|
| 142 | + $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 143 | + } else { |
|
| 144 | + $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext, |
|
| 145 | + $echafauder)); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 150 | + // et si il y a bien un contenu correspondant ou echafaudable |
|
| 151 | + // se rabbatre sur le dist.html du bloc concerne |
|
| 152 | + else { |
|
| 153 | + if ($dir = explode('/', $fond) |
|
| 154 | + and $dir = reset($dir) |
|
| 155 | + and $dir !== $z_contenu |
|
| 156 | + and in_array($dir, $z_blocs) |
|
| 157 | + ) { |
|
| 158 | + $type = substr($fond, strlen("$dir/")); |
|
| 159 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 160 | + $type = $flux['args']['contexte'][$page]; |
|
| 161 | + } |
|
| 162 | + if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 163 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 164 | + } |
|
| 165 | + if ($type == 'page' or $disponible[$type]) { |
|
| 166 | + $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + $squelette = $flux['data']; |
|
| 171 | + } |
|
| 172 | + // layout specifiques par type et compositions : |
|
| 173 | + // body-article.html |
|
| 174 | + // body-sommaire.html |
|
| 175 | + // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 176 | + // meme dossier que body.html |
|
| 177 | + if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 178 | + if (isset($flux['args']['contexte']['type-page']) |
|
| 179 | + and ( |
|
| 180 | + (isset($flux['args']['contexte']['composition']) |
|
| 181 | + and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 182 | + or |
|
| 183 | + file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 184 | + ) |
|
| 185 | + ) { |
|
| 186 | + $flux['data'] = $f; |
|
| 187 | + } |
|
| 188 | + } elseif ($fond == 'structure' |
|
| 189 | + and z_sanitize_var_zajax() |
|
| 190 | + and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 191 | + ) { |
|
| 192 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 193 | + } // chercher le fond correspondant a la composition |
|
| 194 | + elseif (isset($flux['args']['contexte']['composition']) |
|
| 195 | + and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 196 | + and $dir = substr($fond, $prefix_length) |
|
| 197 | + and $dir = explode('/', $dir) |
|
| 198 | + and $dir = reset($dir) |
|
| 199 | + and in_array($dir, $z_blocs) |
|
| 200 | + and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 201 | + ) { |
|
| 202 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + return $flux; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function z_blocs($espace_prive = false) { |
| 216 | - if ($espace_prive) { |
|
| 217 | - return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array( |
|
| 218 | - 'contenu', |
|
| 219 | - 'navigation', |
|
| 220 | - 'extra', |
|
| 221 | - 'head', |
|
| 222 | - 'hierarchie', |
|
| 223 | - 'top' |
|
| 224 | - )); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu')); |
|
| 216 | + if ($espace_prive) { |
|
| 217 | + return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array( |
|
| 218 | + 'contenu', |
|
| 219 | + 'navigation', |
|
| 220 | + 'extra', |
|
| 221 | + 'head', |
|
| 222 | + 'hierarchie', |
|
| 223 | + 'top' |
|
| 224 | + )); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu')); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | * @return mixed |
| 240 | 240 | */ |
| 241 | 241 | function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) { |
| 242 | - if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 243 | - return $d; |
|
| 244 | - } |
|
| 242 | + if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 243 | + return $d; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - return $echafauder ? z_echafaudable($type) : false; |
|
| 246 | + return $echafauder ? z_echafaudable($type) : false; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -257,13 +257,13 @@ discard block |
||
| 257 | 257 | * `true` si on peut l'utiliser, `false` sinon. |
| 258 | 258 | **/ |
| 259 | 259 | function z_fond_valide($squelette) { |
| 260 | - if (!_ZCORE_EXCLURE_PATH |
|
| 261 | - or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 262 | - ) { |
|
| 263 | - return true; |
|
| 264 | - } |
|
| 260 | + if (!_ZCORE_EXCLURE_PATH |
|
| 261 | + or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 262 | + ) { |
|
| 263 | + return true; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - return false; |
|
| 266 | + return false; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -281,14 +281,14 @@ discard block |
||
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | 283 | function z_trouver_bloc($prefix_path, $bloc, $fond, $ext) { |
| 284 | - if ( |
|
| 285 | - (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 286 | - or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 287 | - ) { |
|
| 288 | - return substr($f, 0, -strlen(".$ext")); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return ""; |
|
| 284 | + if ( |
|
| 285 | + (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 286 | + or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 287 | + ) { |
|
| 288 | + return substr($f, 0, -strlen(".$ext")); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return ""; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -300,51 +300,51 @@ discard block |
||
| 300 | 300 | * @return bool |
| 301 | 301 | */ |
| 302 | 302 | function z_echafaudable($type) { |
| 303 | - static $pages = null; |
|
| 304 | - static $echafaudable = array(); |
|
| 305 | - if (isset($echafaudable[$type])) { |
|
| 306 | - return $echafaudable[$type]; |
|
| 307 | - } |
|
| 308 | - if (preg_match(',[^\w],', $type)) { |
|
| 309 | - return $echafaudable[$type] = false; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - if (test_espace_prive()) { |
|
| 313 | - if (!function_exists('trouver_objet_exec')) { |
|
| 314 | - include_spip('inc/pipelines_ecrire'); |
|
| 315 | - } |
|
| 316 | - if ($e = trouver_objet_exec($type)) { |
|
| 317 | - return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e); |
|
| 318 | - } else { |
|
| 319 | - // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 320 | - if (($t = objet_type($type, false)) !== $type |
|
| 321 | - and $e = trouver_objet_exec($t) |
|
| 322 | - ) { |
|
| 323 | - return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t); |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } else { |
|
| 327 | - if (is_null($pages)) { |
|
| 328 | - $pages = array(); |
|
| 329 | - $liste = lister_tables_objets_sql(); |
|
| 330 | - foreach ($liste as $t => $d) { |
|
| 331 | - if ($d['page']) { |
|
| 332 | - $pages[$d['page']] = array($d['table_objet'], $t); |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - if (!isset($pages[$type])) { |
|
| 337 | - return $echafaudable[$type] = false; |
|
| 338 | - } |
|
| 339 | - if (count($pages[$type]) == 2) { |
|
| 340 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | - $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - return $echafaudable[$type] = $pages[$type]; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - return $echafaudable[$type] = false; |
|
| 303 | + static $pages = null; |
|
| 304 | + static $echafaudable = array(); |
|
| 305 | + if (isset($echafaudable[$type])) { |
|
| 306 | + return $echafaudable[$type]; |
|
| 307 | + } |
|
| 308 | + if (preg_match(',[^\w],', $type)) { |
|
| 309 | + return $echafaudable[$type] = false; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + if (test_espace_prive()) { |
|
| 313 | + if (!function_exists('trouver_objet_exec')) { |
|
| 314 | + include_spip('inc/pipelines_ecrire'); |
|
| 315 | + } |
|
| 316 | + if ($e = trouver_objet_exec($type)) { |
|
| 317 | + return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e); |
|
| 318 | + } else { |
|
| 319 | + // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 320 | + if (($t = objet_type($type, false)) !== $type |
|
| 321 | + and $e = trouver_objet_exec($t) |
|
| 322 | + ) { |
|
| 323 | + return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } else { |
|
| 327 | + if (is_null($pages)) { |
|
| 328 | + $pages = array(); |
|
| 329 | + $liste = lister_tables_objets_sql(); |
|
| 330 | + foreach ($liste as $t => $d) { |
|
| 331 | + if ($d['page']) { |
|
| 332 | + $pages[$d['page']] = array($d['table_objet'], $t); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + if (!isset($pages[$type])) { |
|
| 337 | + return $echafaudable[$type] = false; |
|
| 338 | + } |
|
| 339 | + if (count($pages[$type]) == 2) { |
|
| 340 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | + $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + return $echafaudable[$type] = $pages[$type]; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + return $echafaudable[$type] = false; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
@@ -361,46 +361,46 @@ discard block |
||
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | function prive_echafauder_dist($exec, $table, $table_sql, $desc_exec, $ext) { |
| 364 | - $scaffold = ""; |
|
| 365 | - |
|
| 366 | - // page objet ou objet_edit |
|
| 367 | - if (is_array($desc_exec)) { |
|
| 368 | - $type = $desc_exec['type']; |
|
| 369 | - $primary = $desc_exec['id_table_objet']; |
|
| 370 | - |
|
| 371 | - if ($desc_exec['edition'] === false) { |
|
| 372 | - $fond = "objet"; |
|
| 373 | - } else { |
|
| 374 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 375 | - $desc = $trouver_table($table_sql); |
|
| 376 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 377 | - $fond = 'objet_edit'; |
|
| 378 | - } else { |
|
| 379 | - $fond = 'objet_edit.sans_rubrique'; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - $dir = z_blocs(test_espace_prive()); |
|
| 383 | - $dir = reset($dir); |
|
| 384 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>"; |
|
| 385 | - } // page objets |
|
| 386 | - elseif ($type = $desc_exec and strpos($type, "/") === false) { |
|
| 387 | - $dir = z_blocs(test_espace_prive()); |
|
| 388 | - $dir = reset($dir); |
|
| 389 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />"; |
|
| 390 | - } |
|
| 391 | - // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 392 | - // et objet et tire de $table |
|
| 393 | - elseif ($fond = $desc_exec) { |
|
| 394 | - $dir = md5(dirname($fond)); |
|
| 395 | - $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />"; |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false); |
|
| 399 | - $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 400 | - $f = $base_dir . "$exec"; |
|
| 401 | - ecrire_fichier("$f.$ext", $scaffold); |
|
| 402 | - |
|
| 403 | - return $f; |
|
| 364 | + $scaffold = ""; |
|
| 365 | + |
|
| 366 | + // page objet ou objet_edit |
|
| 367 | + if (is_array($desc_exec)) { |
|
| 368 | + $type = $desc_exec['type']; |
|
| 369 | + $primary = $desc_exec['id_table_objet']; |
|
| 370 | + |
|
| 371 | + if ($desc_exec['edition'] === false) { |
|
| 372 | + $fond = "objet"; |
|
| 373 | + } else { |
|
| 374 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 375 | + $desc = $trouver_table($table_sql); |
|
| 376 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 377 | + $fond = 'objet_edit'; |
|
| 378 | + } else { |
|
| 379 | + $fond = 'objet_edit.sans_rubrique'; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + $dir = z_blocs(test_espace_prive()); |
|
| 383 | + $dir = reset($dir); |
|
| 384 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>"; |
|
| 385 | + } // page objets |
|
| 386 | + elseif ($type = $desc_exec and strpos($type, "/") === false) { |
|
| 387 | + $dir = z_blocs(test_espace_prive()); |
|
| 388 | + $dir = reset($dir); |
|
| 389 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />"; |
|
| 390 | + } |
|
| 391 | + // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 392 | + // et objet et tire de $table |
|
| 393 | + elseif ($fond = $desc_exec) { |
|
| 394 | + $dir = md5(dirname($fond)); |
|
| 395 | + $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />"; |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false); |
|
| 399 | + $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 400 | + $f = $base_dir . "$exec"; |
|
| 401 | + ecrire_fichier("$f.$ext", $scaffold); |
|
| 402 | + |
|
| 403 | + return $f; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -409,16 +409,16 @@ discard block |
||
| 409 | 409 | * @return bool|string |
| 410 | 410 | */ |
| 411 | 411 | function z_sanitize_var_zajax() { |
| 412 | - $z_ajax = _request('var_zajax'); |
|
| 413 | - if (!$z_ajax) { |
|
| 414 | - return false; |
|
| 415 | - } |
|
| 416 | - if (!$z_blocs = z_blocs(test_espace_prive()) |
|
| 417 | - or !in_array($z_ajax, $z_blocs) |
|
| 418 | - ) { |
|
| 419 | - set_request('var_zajax'); // enlever cette demande incongrue |
|
| 420 | - $z_ajax = false; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - return $z_ajax; |
|
| 412 | + $z_ajax = _request('var_zajax'); |
|
| 413 | + if (!$z_ajax) { |
|
| 414 | + return false; |
|
| 415 | + } |
|
| 416 | + if (!$z_blocs = z_blocs(test_espace_prive()) |
|
| 417 | + or !in_array($z_ajax, $z_blocs) |
|
| 418 | + ) { |
|
| 419 | + set_request('var_zajax'); // enlever cette demande incongrue |
|
| 420 | + $z_ajax = false; |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + return $z_ajax; |
|
| 424 | 424 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * Code PHP compilé de la boucle |
| 34 | 34 | **/ |
| 35 | 35 | function boucle_DEFAUT_dist($id_boucle, &$boucles) { |
| 36 | - return calculer_boucle($id_boucle, $boucles); |
|
| 36 | + return calculer_boucle($id_boucle, $boucles); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Code PHP compilé de la boucle |
| 53 | 53 | **/ |
| 54 | 54 | function boucle_BOUCLE_dist($id_boucle, &$boucles) { |
| 55 | - return calculer_boucle($id_boucle, $boucles); |
|
| 55 | + return calculer_boucle($id_boucle, $boucles); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | * Code PHP compilé de la boucle |
| 83 | 83 | **/ |
| 84 | 84 | function boucle_HIERARCHIE_dist($id_boucle, &$boucles) { |
| 85 | - $boucle = &$boucles[$id_boucle]; |
|
| 86 | - $id_table = $boucle->id_table . ".id_rubrique"; |
|
| 85 | + $boucle = &$boucles[$id_boucle]; |
|
| 86 | + $id_table = $boucle->id_table . ".id_rubrique"; |
|
| 87 | 87 | |
| 88 | - // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 89 | - // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 90 | - // ou {id_article} qui positionne aussi le {tout} |
|
| 88 | + // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 89 | + // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 90 | + // ou {id_article} qui positionne aussi le {tout} |
|
| 91 | 91 | |
| 92 | - $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 93 | - . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 94 | - . ")))\n\t\treturn '';\n\t" |
|
| 95 | - . "include_spip('inc/rubriques');\n\t" |
|
| 96 | - . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 97 | - . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
|
| 98 | - . ");\n\t" |
|
| 99 | - . 'if (!$hierarchie) return "";' . "\n\t"; |
|
| 92 | + $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 93 | + . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 94 | + . ")))\n\t\treturn '';\n\t" |
|
| 95 | + . "include_spip('inc/rubriques');\n\t" |
|
| 96 | + . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 97 | + . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
|
| 98 | + . ");\n\t" |
|
| 99 | + . 'if (!$hierarchie) return "";' . "\n\t"; |
|
| 100 | 100 | |
| 101 | - $boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 101 | + $boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 102 | 102 | |
| 103 | - $order = "FIELD($id_table, \$hierarchie)"; |
|
| 104 | - if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != " DESC") { |
|
| 105 | - $boucle->default_order[] = "\"$order\""; |
|
| 106 | - } else { |
|
| 107 | - $boucle->default_order[0] = "\"$order DESC\""; |
|
| 108 | - } |
|
| 103 | + $order = "FIELD($id_table, \$hierarchie)"; |
|
| 104 | + if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != " DESC") { |
|
| 105 | + $boucle->default_order[] = "\"$order\""; |
|
| 106 | + } else { |
|
| 107 | + $boucle->default_order[0] = "\"$order DESC\""; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - return calculer_boucle($id_boucle, $boucles); |
|
| 110 | + return calculer_boucle($id_boucle, $boucles); |
|
| 111 | 111 | } |