@@ -15,38 +15,38 @@ discard block |
||
| 15 | 15 | // http://doc.spip.org/@action_editer_auteur_dist |
| 16 | 16 | function action_editer_auteur_dist($arg=null) { |
| 17 | 17 | |
| 18 | - if (is_null($arg)){ |
|
| 19 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 20 | - $arg = $securiser_action(); |
|
| 21 | - } |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - // si id_auteur n'est pas un nombre, c'est une creation |
|
| 25 | - if (!$id_auteur = intval($arg)) { |
|
| 26 | - |
|
| 27 | - if (($id_auteur = auteur_inserer()) > 0){ |
|
| 28 | - |
|
| 29 | - # cf. GROS HACK |
|
| 30 | - # recuperer l'eventuel logo charge avant la creation |
|
| 31 | - # ils ont un id = 0-id_auteur de la session |
|
| 32 | - $id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur']; |
|
| 33 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 34 | - if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'on')) |
|
| 35 | - rename($logo, str_replace($id_hack, $id_auteur, $logo)); |
|
| 36 | - if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'off')) |
|
| 37 | - rename($logo, str_replace($id_hack, $id_auteur, $logo)); |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - // Enregistre l'envoi dans la BD |
|
| 42 | - $err = ""; |
|
| 43 | - if ($id_auteur > 0) |
|
| 44 | - $err = auteur_modifier($id_auteur); |
|
| 45 | - |
|
| 46 | - if ($err) |
|
| 47 | - spip_log("echec editeur auteur: $err",_LOG_ERREUR); |
|
| 48 | - |
|
| 49 | - return array($id_auteur,$err); |
|
| 18 | + if (is_null($arg)){ |
|
| 19 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 20 | + $arg = $securiser_action(); |
|
| 21 | + } |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + // si id_auteur n'est pas un nombre, c'est une creation |
|
| 25 | + if (!$id_auteur = intval($arg)) { |
|
| 26 | + |
|
| 27 | + if (($id_auteur = auteur_inserer()) > 0){ |
|
| 28 | + |
|
| 29 | + # cf. GROS HACK |
|
| 30 | + # recuperer l'eventuel logo charge avant la creation |
|
| 31 | + # ils ont un id = 0-id_auteur de la session |
|
| 32 | + $id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur']; |
|
| 33 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 34 | + if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'on')) |
|
| 35 | + rename($logo, str_replace($id_hack, $id_auteur, $logo)); |
|
| 36 | + if (list($logo) = $chercher_logo($id_hack, 'id_auteur', 'off')) |
|
| 37 | + rename($logo, str_replace($id_hack, $id_auteur, $logo)); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + // Enregistre l'envoi dans la BD |
|
| 42 | + $err = ""; |
|
| 43 | + if ($id_auteur > 0) |
|
| 44 | + $err = auteur_modifier($id_auteur); |
|
| 45 | + |
|
| 46 | + if ($err) |
|
| 47 | + spip_log("echec editeur auteur: $err",_LOG_ERREUR); |
|
| 48 | + |
|
| 49 | + return array($id_auteur,$err); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,34 +56,34 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function auteur_inserer($source=null) { |
| 58 | 58 | |
| 59 | - // Ce qu'on va demander comme modifications |
|
| 60 | - $champs = array(); |
|
| 61 | - $champs['source'] = $source?$source:'spip'; |
|
| 62 | - |
|
| 63 | - $champs['login'] = ''; |
|
| 64 | - $champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue |
|
| 65 | - $champs['webmestre'] = 'non'; |
|
| 66 | - |
|
| 67 | - // Envoyer aux plugins |
|
| 68 | - $champs = pipeline('pre_insertion', |
|
| 69 | - array( |
|
| 70 | - 'args' => array( |
|
| 71 | - 'table' => 'spip_auteurs', |
|
| 72 | - ), |
|
| 73 | - 'data' => $champs |
|
| 74 | - ) |
|
| 75 | - ); |
|
| 76 | - $id_auteur = sql_insertq("spip_auteurs", $champs); |
|
| 77 | - pipeline('post_insertion', |
|
| 78 | - array( |
|
| 79 | - 'args' => array( |
|
| 80 | - 'table' => 'spip_auteurs', |
|
| 81 | - 'id_objet' => $id_auteur |
|
| 82 | - ), |
|
| 83 | - 'data' => $champs |
|
| 84 | - ) |
|
| 85 | - ); |
|
| 86 | - return $id_auteur; |
|
| 59 | + // Ce qu'on va demander comme modifications |
|
| 60 | + $champs = array(); |
|
| 61 | + $champs['source'] = $source?$source:'spip'; |
|
| 62 | + |
|
| 63 | + $champs['login'] = ''; |
|
| 64 | + $champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue |
|
| 65 | + $champs['webmestre'] = 'non'; |
|
| 66 | + |
|
| 67 | + // Envoyer aux plugins |
|
| 68 | + $champs = pipeline('pre_insertion', |
|
| 69 | + array( |
|
| 70 | + 'args' => array( |
|
| 71 | + 'table' => 'spip_auteurs', |
|
| 72 | + ), |
|
| 73 | + 'data' => $champs |
|
| 74 | + ) |
|
| 75 | + ); |
|
| 76 | + $id_auteur = sql_insertq("spip_auteurs", $champs); |
|
| 77 | + pipeline('post_insertion', |
|
| 78 | + array( |
|
| 79 | + 'args' => array( |
|
| 80 | + 'table' => 'spip_auteurs', |
|
| 81 | + 'id_objet' => $id_auteur |
|
| 82 | + ), |
|
| 83 | + 'data' => $champs |
|
| 84 | + ) |
|
| 85 | + ); |
|
| 86 | + return $id_auteur; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
@@ -99,55 +99,55 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | function auteur_modifier($id_auteur, $set = null, $force_update=false) { |
| 101 | 101 | |
| 102 | - include_spip('inc/modifier'); |
|
| 103 | - include_spip('inc/filtres'); |
|
| 104 | - $c = collecter_requests( |
|
| 105 | - // white list |
|
| 106 | - objet_info('auteur','champs_editables'), |
|
| 107 | - // black list |
|
| 108 | - $force_update?array():array('webmestre','pass','login'), |
|
| 109 | - // donnees eventuellement fournies |
|
| 110 | - $set |
|
| 111 | - ); |
|
| 112 | - |
|
| 113 | - if ($err = objet_modifier_champs('auteur', $id_auteur, |
|
| 114 | - array( |
|
| 115 | - 'data' => $set, |
|
| 116 | - 'nonvide' => array('nom' => _T('ecrire:item_nouvel_auteur')) |
|
| 117 | - ), |
|
| 118 | - $c)) |
|
| 119 | - return $err; |
|
| 120 | - $session = $c; |
|
| 121 | - |
|
| 122 | - $err = ''; |
|
| 123 | - if (!$force_update){ |
|
| 124 | - // Modification de statut, changement de rubrique ? |
|
| 125 | - $c = collecter_requests( |
|
| 126 | - // white list |
|
| 127 | - array( |
|
| 128 | - 'statut', 'new_login','new_pass','login','pass','webmestre','restreintes','id_parent' |
|
| 129 | - ), |
|
| 130 | - // black list |
|
| 131 | - array(), |
|
| 132 | - // donnees eventuellement fournies |
|
| 133 | - $set |
|
| 134 | - ); |
|
| 135 | - if (isset($c['new_login']) AND !isset($c['login'])) |
|
| 136 | - $c['login'] = $c['new_login']; |
|
| 137 | - if (isset($c['new_pass']) AND !isset($c['pass'])) |
|
| 138 | - $c['pass'] = $c['new_pass']; |
|
| 139 | - $err = auteur_instituer($id_auteur, $c); |
|
| 140 | - $session = array_merge($session,$c); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // .. mettre a jour les sessions de cet auteur |
|
| 144 | - include_spip('inc/session'); |
|
| 145 | - $session['id_auteur'] = $id_auteur; |
|
| 146 | - unset($session['new_login']); |
|
| 147 | - unset($session['new_pass']); |
|
| 148 | - actualiser_sessions($session); |
|
| 149 | - |
|
| 150 | - return $err; |
|
| 102 | + include_spip('inc/modifier'); |
|
| 103 | + include_spip('inc/filtres'); |
|
| 104 | + $c = collecter_requests( |
|
| 105 | + // white list |
|
| 106 | + objet_info('auteur','champs_editables'), |
|
| 107 | + // black list |
|
| 108 | + $force_update?array():array('webmestre','pass','login'), |
|
| 109 | + // donnees eventuellement fournies |
|
| 110 | + $set |
|
| 111 | + ); |
|
| 112 | + |
|
| 113 | + if ($err = objet_modifier_champs('auteur', $id_auteur, |
|
| 114 | + array( |
|
| 115 | + 'data' => $set, |
|
| 116 | + 'nonvide' => array('nom' => _T('ecrire:item_nouvel_auteur')) |
|
| 117 | + ), |
|
| 118 | + $c)) |
|
| 119 | + return $err; |
|
| 120 | + $session = $c; |
|
| 121 | + |
|
| 122 | + $err = ''; |
|
| 123 | + if (!$force_update){ |
|
| 124 | + // Modification de statut, changement de rubrique ? |
|
| 125 | + $c = collecter_requests( |
|
| 126 | + // white list |
|
| 127 | + array( |
|
| 128 | + 'statut', 'new_login','new_pass','login','pass','webmestre','restreintes','id_parent' |
|
| 129 | + ), |
|
| 130 | + // black list |
|
| 131 | + array(), |
|
| 132 | + // donnees eventuellement fournies |
|
| 133 | + $set |
|
| 134 | + ); |
|
| 135 | + if (isset($c['new_login']) AND !isset($c['login'])) |
|
| 136 | + $c['login'] = $c['new_login']; |
|
| 137 | + if (isset($c['new_pass']) AND !isset($c['pass'])) |
|
| 138 | + $c['pass'] = $c['new_pass']; |
|
| 139 | + $err = auteur_instituer($id_auteur, $c); |
|
| 140 | + $session = array_merge($session,$c); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // .. mettre a jour les sessions de cet auteur |
|
| 144 | + include_spip('inc/session'); |
|
| 145 | + $session['id_auteur'] = $id_auteur; |
|
| 146 | + unset($session['new_login']); |
|
| 147 | + unset($session['new_pass']); |
|
| 148 | + actualiser_sessions($session); |
|
| 149 | + |
|
| 150 | + return $err; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | * @return string |
| 166 | 166 | */ |
| 167 | 167 | function auteur_associer($id_auteur,$objets, $qualif = null){ |
| 168 | - include_spip('action/editer_liens'); |
|
| 169 | - return objet_associer(array('auteur'=>$id_auteur), $objets, $qualif); |
|
| 168 | + include_spip('action/editer_liens'); |
|
| 169 | + return objet_associer(array('auteur'=>$id_auteur), $objets, $qualif); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * @return string |
| 178 | 178 | */ |
| 179 | 179 | function auteur_referent($id_auteur,$c){ |
| 180 | - return auteur_associer($id_auteur,$c); |
|
| 180 | + return auteur_associer($id_auteur,$c); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | * @return string |
| 193 | 193 | */ |
| 194 | 194 | function auteur_dissocier($id_auteur,$objets){ |
| 195 | - include_spip('action/editer_liens'); |
|
| 196 | - return objet_dissocier(array('auteur'=>$id_auteur), $objets); |
|
| 195 | + include_spip('action/editer_liens'); |
|
| 196 | + return objet_dissocier(array('auteur'=>$id_auteur), $objets); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | * @return bool|int |
| 211 | 211 | */ |
| 212 | 212 | function auteur_qualifier($id_auteur,$objets,$qualif){ |
| 213 | - include_spip('action/editer_liens'); |
|
| 214 | - return objet_qualifier_liens(array('auteur'=>$id_auteur), $objets, $qualif); |
|
| 213 | + include_spip('action/editer_liens'); |
|
| 214 | + return objet_qualifier_liens(array('auteur'=>$id_auteur), $objets, $qualif); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -224,114 +224,114 @@ discard block |
||
| 224 | 224 | * @return bool|string |
| 225 | 225 | */ |
| 226 | 226 | function auteur_instituer($id_auteur, $c, $force_webmestre = false) { |
| 227 | - if (!$id_auteur=intval($id_auteur)) |
|
| 228 | - return false; |
|
| 229 | - $erreurs = array(); // contiendra les differentes erreurs a traduire par _T() |
|
| 230 | - $champs = array(); |
|
| 231 | - |
|
| 232 | - // les memoriser pour les faire passer dans le pipeline pre_edition |
|
| 233 | - if (isset($c['login']) AND strlen($c['login'])) |
|
| 234 | - $champs['login'] = $c['login']; |
|
| 235 | - if (isset($c['pass']) AND strlen($c['pass'])) |
|
| 236 | - $champs['pass'] = $c['pass']; |
|
| 237 | - |
|
| 238 | - $statut = $statut_ancien = sql_getfetsel('statut','spip_auteurs','id_auteur='.intval($id_auteur)); |
|
| 227 | + if (!$id_auteur=intval($id_auteur)) |
|
| 228 | + return false; |
|
| 229 | + $erreurs = array(); // contiendra les differentes erreurs a traduire par _T() |
|
| 230 | + $champs = array(); |
|
| 231 | + |
|
| 232 | + // les memoriser pour les faire passer dans le pipeline pre_edition |
|
| 233 | + if (isset($c['login']) AND strlen($c['login'])) |
|
| 234 | + $champs['login'] = $c['login']; |
|
| 235 | + if (isset($c['pass']) AND strlen($c['pass'])) |
|
| 236 | + $champs['pass'] = $c['pass']; |
|
| 237 | + |
|
| 238 | + $statut = $statut_ancien = sql_getfetsel('statut','spip_auteurs','id_auteur='.intval($id_auteur)); |
|
| 239 | 239 | |
| 240 | - if (isset($c['statut']) |
|
| 241 | - AND (autoriser('modifier', 'auteur', $id_auteur,null, array('statut' => $c['statut'])))) |
|
| 242 | - $statut = $champs['statut'] = $c['statut']; |
|
| 243 | - |
|
| 244 | - // Restreindre avant de declarer l'auteur |
|
| 245 | - // (section critique sur les droits) |
|
| 246 | - if ($c['id_parent']) { |
|
| 247 | - if (is_array($c['restreintes'])) |
|
| 248 | - $c['restreintes'][] = $c['id_parent']; |
|
| 249 | - else |
|
| 250 | - $c['restreintes'] = array($c['id_parent']); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - if (isset($c['webmestre']) |
|
| 254 | - AND ($force_webmestre OR autoriser('modifier', 'auteur', $id_auteur,null, array('webmestre' => '?')))) |
|
| 255 | - $champs['webmestre'] = $c['webmestre']=='oui'?'oui':'non'; |
|
| 240 | + if (isset($c['statut']) |
|
| 241 | + AND (autoriser('modifier', 'auteur', $id_auteur,null, array('statut' => $c['statut'])))) |
|
| 242 | + $statut = $champs['statut'] = $c['statut']; |
|
| 243 | + |
|
| 244 | + // Restreindre avant de declarer l'auteur |
|
| 245 | + // (section critique sur les droits) |
|
| 246 | + if ($c['id_parent']) { |
|
| 247 | + if (is_array($c['restreintes'])) |
|
| 248 | + $c['restreintes'][] = $c['id_parent']; |
|
| 249 | + else |
|
| 250 | + $c['restreintes'] = array($c['id_parent']); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + if (isset($c['webmestre']) |
|
| 254 | + AND ($force_webmestre OR autoriser('modifier', 'auteur', $id_auteur,null, array('webmestre' => '?')))) |
|
| 255 | + $champs['webmestre'] = $c['webmestre']=='oui'?'oui':'non'; |
|
| 256 | 256 | |
| 257 | - // Envoyer aux plugins |
|
| 258 | - $champs = pipeline('pre_edition', |
|
| 259 | - array( |
|
| 260 | - 'args' => array( |
|
| 261 | - 'table' => 'spip_auteurs', |
|
| 262 | - 'id_objet' => $id_auteur, |
|
| 263 | - 'action' => 'instituer', |
|
| 264 | - 'statut_ancien' => $statut_ancien, |
|
| 265 | - ), |
|
| 266 | - 'data' => $champs |
|
| 267 | - ) |
|
| 268 | - ); |
|
| 257 | + // Envoyer aux plugins |
|
| 258 | + $champs = pipeline('pre_edition', |
|
| 259 | + array( |
|
| 260 | + 'args' => array( |
|
| 261 | + 'table' => 'spip_auteurs', |
|
| 262 | + 'id_objet' => $id_auteur, |
|
| 263 | + 'action' => 'instituer', |
|
| 264 | + 'statut_ancien' => $statut_ancien, |
|
| 265 | + ), |
|
| 266 | + 'data' => $champs |
|
| 267 | + ) |
|
| 268 | + ); |
|
| 269 | 269 | |
| 270 | - if (is_array($c['restreintes']) |
|
| 271 | - AND autoriser('modifier', 'auteur', $id_auteur, NULL, array('restreint'=>$c['restreintes']))) { |
|
| 272 | - $rubriques = array_map('intval',$c['restreintes']); |
|
| 273 | - $rubriques = array_unique($rubriques); |
|
| 274 | - $rubriques = array_diff($rubriques,array(0)); |
|
| 275 | - auteur_dissocier($id_auteur, array('rubrique'=>'*')); |
|
| 276 | - auteur_associer($id_auteur,array('rubrique'=>$rubriques)); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - $flag_ecrire_acces = false; |
|
| 280 | - // commencer par traiter les cas particuliers des logins et pass |
|
| 281 | - // avant les autres ecritures en base |
|
| 282 | - if (isset($champs['login']) OR isset($champs['pass'])){ |
|
| 283 | - $auth_methode = sql_getfetsel('source','spip_auteurs','id_auteur='.intval($id_auteur)); |
|
| 284 | - include_spip('inc/auth'); |
|
| 285 | - if (isset($champs['login']) AND strlen($champs['login'])) |
|
| 286 | - if (!auth_modifier_login($auth_methode, $champs['login'], $id_auteur)) |
|
| 287 | - $erreurs[] = 'ecrire:impossible_modifier_login_auteur'; |
|
| 288 | - if (isset($champs['pass']) AND strlen($champs['pass'])){ |
|
| 289 | - $champs['login'] = sql_getfetsel('login','spip_auteurs','id_auteur='.intval($id_auteur)); |
|
| 290 | - if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) |
|
| 291 | - $erreurs[] = 'ecrire:impossible_modifier_pass_auteur'; |
|
| 292 | - } |
|
| 293 | - unset($champs['login']); |
|
| 294 | - unset($champs['pass']); |
|
| 295 | - $flag_ecrire_acces = true; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - if (!count($champs)) return implode(' ', array_map('_T', $erreurs)); |
|
| 299 | - sql_updateq('spip_auteurs', $champs , 'id_auteur='.$id_auteur); |
|
| 300 | - |
|
| 301 | - // .. mettre a jour les fichiers .htpasswd et .htpasswd-admin |
|
| 302 | - if ($flag_ecrire_acces |
|
| 303 | - OR isset($champs['statut']) |
|
| 304 | - ) { |
|
| 305 | - include_spip('inc/acces'); |
|
| 306 | - ecrire_acces(); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // Invalider les caches |
|
| 310 | - include_spip('inc/invalideur'); |
|
| 311 | - suivre_invalideur("id='auteur/$id_auteur'"); |
|
| 270 | + if (is_array($c['restreintes']) |
|
| 271 | + AND autoriser('modifier', 'auteur', $id_auteur, NULL, array('restreint'=>$c['restreintes']))) { |
|
| 272 | + $rubriques = array_map('intval',$c['restreintes']); |
|
| 273 | + $rubriques = array_unique($rubriques); |
|
| 274 | + $rubriques = array_diff($rubriques,array(0)); |
|
| 275 | + auteur_dissocier($id_auteur, array('rubrique'=>'*')); |
|
| 276 | + auteur_associer($id_auteur,array('rubrique'=>$rubriques)); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + $flag_ecrire_acces = false; |
|
| 280 | + // commencer par traiter les cas particuliers des logins et pass |
|
| 281 | + // avant les autres ecritures en base |
|
| 282 | + if (isset($champs['login']) OR isset($champs['pass'])){ |
|
| 283 | + $auth_methode = sql_getfetsel('source','spip_auteurs','id_auteur='.intval($id_auteur)); |
|
| 284 | + include_spip('inc/auth'); |
|
| 285 | + if (isset($champs['login']) AND strlen($champs['login'])) |
|
| 286 | + if (!auth_modifier_login($auth_methode, $champs['login'], $id_auteur)) |
|
| 287 | + $erreurs[] = 'ecrire:impossible_modifier_login_auteur'; |
|
| 288 | + if (isset($champs['pass']) AND strlen($champs['pass'])){ |
|
| 289 | + $champs['login'] = sql_getfetsel('login','spip_auteurs','id_auteur='.intval($id_auteur)); |
|
| 290 | + if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) |
|
| 291 | + $erreurs[] = 'ecrire:impossible_modifier_pass_auteur'; |
|
| 292 | + } |
|
| 293 | + unset($champs['login']); |
|
| 294 | + unset($champs['pass']); |
|
| 295 | + $flag_ecrire_acces = true; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + if (!count($champs)) return implode(' ', array_map('_T', $erreurs)); |
|
| 299 | + sql_updateq('spip_auteurs', $champs , 'id_auteur='.$id_auteur); |
|
| 300 | + |
|
| 301 | + // .. mettre a jour les fichiers .htpasswd et .htpasswd-admin |
|
| 302 | + if ($flag_ecrire_acces |
|
| 303 | + OR isset($champs['statut']) |
|
| 304 | + ) { |
|
| 305 | + include_spip('inc/acces'); |
|
| 306 | + ecrire_acces(); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // Invalider les caches |
|
| 310 | + include_spip('inc/invalideur'); |
|
| 311 | + suivre_invalideur("id='auteur/$id_auteur'"); |
|
| 312 | 312 | |
| 313 | - // Pipeline |
|
| 314 | - pipeline('post_edition', |
|
| 315 | - array( |
|
| 316 | - 'args' => array( |
|
| 317 | - 'table' => 'spip_auteurs', |
|
| 318 | - 'id_objet' => $id_auteur, |
|
| 319 | - 'action' => 'instituer', |
|
| 320 | - 'statut_ancien' => $statut_ancien, |
|
| 321 | - ), |
|
| 322 | - 'data' => $champs |
|
| 323 | - ) |
|
| 324 | - ); |
|
| 325 | - |
|
| 326 | - |
|
| 327 | - // Notifications |
|
| 328 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 329 | - $notifications('instituerauteur', $id_auteur, |
|
| 330 | - array('statut' => $statut, 'statut_ancien' => $statut_ancien) |
|
| 331 | - ); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - return implode(' ', array_map('_T', $erreurs)); |
|
| 313 | + // Pipeline |
|
| 314 | + pipeline('post_edition', |
|
| 315 | + array( |
|
| 316 | + 'args' => array( |
|
| 317 | + 'table' => 'spip_auteurs', |
|
| 318 | + 'id_objet' => $id_auteur, |
|
| 319 | + 'action' => 'instituer', |
|
| 320 | + 'statut_ancien' => $statut_ancien, |
|
| 321 | + ), |
|
| 322 | + 'data' => $champs |
|
| 323 | + ) |
|
| 324 | + ); |
|
| 325 | + |
|
| 326 | + |
|
| 327 | + // Notifications |
|
| 328 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 329 | + $notifications('instituerauteur', $id_auteur, |
|
| 330 | + array('statut' => $statut, 'statut_ancien' => $statut_ancien) |
|
| 331 | + ); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + return implode(' ', array_map('_T', $erreurs)); |
|
| 335 | 335 | |
| 336 | 336 | } |
| 337 | 337 | |
@@ -339,17 +339,17 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | |
| 341 | 341 | function insert_auteur($source=null) { |
| 342 | - return auteur_inserer($source); |
|
| 342 | + return auteur_inserer($source); |
|
| 343 | 343 | } |
| 344 | 344 | function auteurs_set($id_auteur, $set = null) { |
| 345 | - return auteur_modifier($id_auteur,$set); |
|
| 345 | + return auteur_modifier($id_auteur,$set); |
|
| 346 | 346 | } |
| 347 | 347 | function instituer_auteur($id_auteur, $c, $force_webmestre = false) { |
| 348 | - return auteur_instituer($id_auteur,$c,$force_webmestre); |
|
| 348 | + return auteur_instituer($id_auteur,$c,$force_webmestre); |
|
| 349 | 349 | } |
| 350 | 350 | // http://doc.spip.org/@revision_auteur |
| 351 | 351 | function revision_auteur($id_auteur, $c=false) { |
| 352 | - return auteur_modifier($id_auteur,$c); |
|
| 352 | + return auteur_modifier($id_auteur,$c); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | ?> |
@@ -17,16 +17,16 @@ |
||
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | 19 | function action_forcer_job_dist(){ |
| 20 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 21 | - $id_job = $securiser_action(); |
|
| 20 | + $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 21 | + $id_job = $securiser_action(); |
|
| 22 | 22 | |
| 23 | - if ($id_job = intval($id_job) |
|
| 24 | - AND autoriser('forcer','job',$id_job) |
|
| 25 | - ){ |
|
| 26 | - include_spip('inc/queue'); |
|
| 27 | - include_spip('inc/genie'); |
|
| 28 | - queue_schedule(array($id_job)); |
|
| 29 | - } |
|
| 23 | + if ($id_job = intval($id_job) |
|
| 24 | + AND autoriser('forcer','job',$id_job) |
|
| 25 | + ){ |
|
| 26 | + include_spip('inc/queue'); |
|
| 27 | + include_spip('inc/genie'); |
|
| 28 | + queue_schedule(array($id_job)); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | } |
| 32 | 32 | |
@@ -17,18 +17,18 @@ |
||
| 17 | 17 | |
| 18 | 18 | function action_confirmer_email_dist() |
| 19 | 19 | { |
| 20 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | - $arg = $securiser_action(); |
|
| 22 | - |
|
| 23 | - include_spip('inc/filtres'); |
|
| 24 | - if ($GLOBALS['visiteur_session']['id_auteur'] AND email_valide($arg)){ |
|
| 25 | - include_spip('action/editer_auteur'); |
|
| 26 | - auteur_modifier($GLOBALS['visiteur_session']['id_auteur'],array('email'=>$arg)); |
|
| 27 | - } |
|
| 28 | - // verifier avant de rediriger pour invalider le message de confirmation |
|
| 29 | - // si ca n'a pas marche |
|
| 30 | - if ($redirect = _request('redirect') AND !$arg == sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($GLOBALS['visiteur_session']))) |
|
| 31 | - $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif',''); |
|
| 20 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | + $arg = $securiser_action(); |
|
| 22 | + |
|
| 23 | + include_spip('inc/filtres'); |
|
| 24 | + if ($GLOBALS['visiteur_session']['id_auteur'] AND email_valide($arg)){ |
|
| 25 | + include_spip('action/editer_auteur'); |
|
| 26 | + auteur_modifier($GLOBALS['visiteur_session']['id_auteur'],array('email'=>$arg)); |
|
| 27 | + } |
|
| 28 | + // verifier avant de rediriger pour invalider le message de confirmation |
|
| 29 | + // si ca n'a pas marche |
|
| 30 | + if ($redirect = _request('redirect') AND !$arg == sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($GLOBALS['visiteur_session']))) |
|
| 31 | + $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif',''); |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | |
@@ -25,26 +25,26 @@ |
||
| 25 | 25 | * "* * * * * curl http://www.mondomaine.tld/spip.php?action=super_cron" |
| 26 | 26 | */ |
| 27 | 27 | function action_super_cron_dist(){ |
| 28 | - // Si fsockopen est possible, on lance le cron via un socket |
|
| 29 | - // en asynchrone |
|
| 30 | - if(function_exists('fsockopen')){ |
|
| 31 | - $url = generer_url_action('cron'); |
|
| 32 | - $parts=parse_url($url); |
|
| 33 | - $fp = fsockopen($parts['host'], |
|
| 34 | - isset($parts['port'])?$parts['port']:80, |
|
| 35 | - $errno, $errstr, 30); |
|
| 36 | - if ($fp) { |
|
| 37 | - $out = "GET ".$parts['path']."?".$parts['query']." HTTP/1.1\r\n"; |
|
| 38 | - $out.= "Host: ".$parts['host']."\r\n"; |
|
| 39 | - $out.= "Connection: Close\r\n\r\n"; |
|
| 40 | - fwrite($fp, $out); |
|
| 41 | - fclose($fp); |
|
| 42 | - return; |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - // ici lancer le cron par un CURL asynchrone si CURL est présent |
|
| 46 | - // TBD |
|
| 28 | + // Si fsockopen est possible, on lance le cron via un socket |
|
| 29 | + // en asynchrone |
|
| 30 | + if(function_exists('fsockopen')){ |
|
| 31 | + $url = generer_url_action('cron'); |
|
| 32 | + $parts=parse_url($url); |
|
| 33 | + $fp = fsockopen($parts['host'], |
|
| 34 | + isset($parts['port'])?$parts['port']:80, |
|
| 35 | + $errno, $errstr, 30); |
|
| 36 | + if ($fp) { |
|
| 37 | + $out = "GET ".$parts['path']."?".$parts['query']." HTTP/1.1\r\n"; |
|
| 38 | + $out.= "Host: ".$parts['host']."\r\n"; |
|
| 39 | + $out.= "Connection: Close\r\n\r\n"; |
|
| 40 | + fwrite($fp, $out); |
|
| 41 | + fclose($fp); |
|
| 42 | + return; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + // ici lancer le cron par un CURL asynchrone si CURL est présent |
|
| 46 | + // TBD |
|
| 47 | 47 | |
| 48 | - return; |
|
| 48 | + return; |
|
| 49 | 49 | } |
| 50 | 50 | ?> |
| 51 | 51 | \ No newline at end of file |
@@ -17,28 +17,28 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | function action_auth_dist() { |
| 19 | 19 | |
| 20 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | - $arg = $securiser_action(); |
|
| 22 | - |
|
| 23 | - if (!preg_match(",^(\w+)[/](.+)$,", $arg, $r)) { |
|
| 24 | - spip_log("action_auth_dist $arg pas compris"); |
|
| 25 | - } |
|
| 26 | - else { |
|
| 27 | - $auth_methode = $r[1]; |
|
| 28 | - $login = $r[2]; |
|
| 29 | - include_spip('inc/auth'); |
|
| 30 | - $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 31 | - |
|
| 32 | - if (is_string($res)){ // Erreur |
|
| 33 | - $redirect = _request('redirect'); |
|
| 34 | - $redirect = parametre_url($redirect,'var_erreur',$res,'&'); |
|
| 35 | - include_spip('inc/headers'); |
|
| 36 | - redirige_par_entete($redirect); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 40 | - auth_loger($res); |
|
| 41 | - } |
|
| 20 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | + $arg = $securiser_action(); |
|
| 22 | + |
|
| 23 | + if (!preg_match(",^(\w+)[/](.+)$,", $arg, $r)) { |
|
| 24 | + spip_log("action_auth_dist $arg pas compris"); |
|
| 25 | + } |
|
| 26 | + else { |
|
| 27 | + $auth_methode = $r[1]; |
|
| 28 | + $login = $r[2]; |
|
| 29 | + include_spip('inc/auth'); |
|
| 30 | + $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 31 | + |
|
| 32 | + if (is_string($res)){ // Erreur |
|
| 33 | + $redirect = _request('redirect'); |
|
| 34 | + $redirect = parametre_url($redirect,'var_erreur',$res,'&'); |
|
| 35 | + include_spip('inc/headers'); |
|
| 36 | + redirige_par_entete($redirect); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 40 | + auth_loger($res); |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | |
@@ -15,56 +15,56 @@ |
||
| 15 | 15 | // http://doc.spip.org/@action_purger_dist |
| 16 | 16 | function action_purger_dist($arg=null) |
| 17 | 17 | { |
| 18 | - if (is_null($arg)) { |
|
| 19 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 20 | - $arg = $securiser_action(); |
|
| 21 | - } |
|
| 18 | + if (is_null($arg)) { |
|
| 19 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 20 | + $arg = $securiser_action(); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - include_spip('inc/invalideur'); |
|
| 23 | + include_spip('inc/invalideur'); |
|
| 24 | 24 | |
| 25 | - spip_log("purger $arg"); |
|
| 25 | + spip_log("purger $arg"); |
|
| 26 | 26 | |
| 27 | - switch ($arg) { |
|
| 28 | - case 'inhibe_cache': |
|
| 29 | - // inhiber le cache pendant 24h |
|
| 30 | - ecrire_meta('cache_inhib',$_SERVER['REQUEST_TIME']+24*3600); |
|
| 31 | - break; |
|
| 32 | - case 'reactive_cache': |
|
| 33 | - effacer_meta('cache_inhib'); |
|
| 34 | - break; |
|
| 27 | + switch ($arg) { |
|
| 28 | + case 'inhibe_cache': |
|
| 29 | + // inhiber le cache pendant 24h |
|
| 30 | + ecrire_meta('cache_inhib',$_SERVER['REQUEST_TIME']+24*3600); |
|
| 31 | + break; |
|
| 32 | + case 'reactive_cache': |
|
| 33 | + effacer_meta('cache_inhib'); |
|
| 34 | + break; |
|
| 35 | 35 | |
| 36 | - case 'cache': |
|
| 37 | - supprime_invalideurs(); |
|
| 38 | - @spip_unlink(_CACHE_RUBRIQUES); |
|
| 39 | - @spip_unlink(_CACHE_CHEMIN); |
|
| 40 | - @spip_unlink(_DIR_TMP."plugin_xml_cache.gz"); |
|
| 41 | - // on ne supprime que _CACHE_PLUGINS_OPT qui declenche la reconstruction des 3 |
|
| 42 | - // _CACHE_PIPELINES _CACHE_PLUGINS_PATH et _CACHE_PLUGINS_FCT |
|
| 43 | - // pour eviter des problemes de concurence |
|
| 44 | - // cf http://core.spip.org/issues/2989 |
|
| 45 | - //@spip_unlink(_CACHE_PIPELINES); |
|
| 46 | - //@spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 47 | - //@spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 48 | - @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 49 | - purger_repertoire(_DIR_CACHE,array('subdir'=>true)); |
|
| 50 | - purger_repertoire(_DIR_AIDE); |
|
| 51 | - purger_repertoire(_DIR_VAR.'cache-css'); |
|
| 52 | - purger_repertoire(_DIR_VAR.'cache-js'); |
|
| 53 | - break; |
|
| 36 | + case 'cache': |
|
| 37 | + supprime_invalideurs(); |
|
| 38 | + @spip_unlink(_CACHE_RUBRIQUES); |
|
| 39 | + @spip_unlink(_CACHE_CHEMIN); |
|
| 40 | + @spip_unlink(_DIR_TMP."plugin_xml_cache.gz"); |
|
| 41 | + // on ne supprime que _CACHE_PLUGINS_OPT qui declenche la reconstruction des 3 |
|
| 42 | + // _CACHE_PIPELINES _CACHE_PLUGINS_PATH et _CACHE_PLUGINS_FCT |
|
| 43 | + // pour eviter des problemes de concurence |
|
| 44 | + // cf http://core.spip.org/issues/2989 |
|
| 45 | + //@spip_unlink(_CACHE_PIPELINES); |
|
| 46 | + //@spip_unlink(_CACHE_PLUGINS_PATH); |
|
| 47 | + //@spip_unlink(_CACHE_PLUGINS_FCT); |
|
| 48 | + @spip_unlink(_CACHE_PLUGINS_OPT); |
|
| 49 | + purger_repertoire(_DIR_CACHE,array('subdir'=>true)); |
|
| 50 | + purger_repertoire(_DIR_AIDE); |
|
| 51 | + purger_repertoire(_DIR_VAR.'cache-css'); |
|
| 52 | + purger_repertoire(_DIR_VAR.'cache-js'); |
|
| 53 | + break; |
|
| 54 | 54 | |
| 55 | - case 'squelettes': |
|
| 56 | - purger_repertoire(_DIR_SKELS); |
|
| 57 | - break; |
|
| 55 | + case 'squelettes': |
|
| 56 | + purger_repertoire(_DIR_SKELS); |
|
| 57 | + break; |
|
| 58 | 58 | |
| 59 | - case 'vignettes': |
|
| 60 | - purger_repertoire(_DIR_VAR,array('subdir'=>true)); |
|
| 61 | - supprime_invalideurs(); |
|
| 62 | - purger_repertoire(_DIR_CACHE); |
|
| 63 | - break; |
|
| 64 | - } |
|
| 59 | + case 'vignettes': |
|
| 60 | + purger_repertoire(_DIR_VAR,array('subdir'=>true)); |
|
| 61 | + supprime_invalideurs(); |
|
| 62 | + purger_repertoire(_DIR_CACHE); |
|
| 63 | + break; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // le faire savoir aux plugins |
|
| 67 | - pipeline('trig_purger',$arg); |
|
| 66 | + // le faire savoir aux plugins |
|
| 67 | + pipeline('trig_purger',$arg); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | ?> |
@@ -18,30 +18,30 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | function action_iconifier_dist() |
| 20 | 20 | { |
| 21 | - include_spip('inc/actions'); |
|
| 22 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 23 | - $arg = $securiser_action(); |
|
| 24 | - $iframe_redirect = _request('iframe_redirect'); |
|
| 21 | + include_spip('inc/actions'); |
|
| 22 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 23 | + $arg = $securiser_action(); |
|
| 24 | + $iframe_redirect = _request('iframe_redirect'); |
|
| 25 | 25 | |
| 26 | - $arg = rawurldecode($arg); |
|
| 26 | + $arg = rawurldecode($arg); |
|
| 27 | 27 | |
| 28 | - if (!preg_match(',^-?\d*(\D)(.*)$,',$arg, $r)) |
|
| 29 | - spip_log("action iconifier: $arg pas compris"); |
|
| 30 | - elseif ($r[1] == '+') |
|
| 31 | - action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source')); |
|
| 32 | - else action_spip_image_effacer_dist($r[2]); |
|
| 28 | + if (!preg_match(',^-?\d*(\D)(.*)$,',$arg, $r)) |
|
| 29 | + spip_log("action iconifier: $arg pas compris"); |
|
| 30 | + elseif ($r[1] == '+') |
|
| 31 | + action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source')); |
|
| 32 | + else action_spip_image_effacer_dist($r[2]); |
|
| 33 | 33 | |
| 34 | - if(_request("iframe") == 'iframe') { |
|
| 35 | - $redirect = urldecode($iframe_redirect)."&iframe=iframe"; |
|
| 36 | - redirige_par_entete(urldecode($redirect)); |
|
| 37 | - } |
|
| 34 | + if(_request("iframe") == 'iframe') { |
|
| 35 | + $redirect = urldecode($iframe_redirect)."&iframe=iframe"; |
|
| 36 | + redirige_par_entete(urldecode($redirect)); |
|
| 37 | + } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // http://doc.spip.org/@action_spip_image_effacer_dist |
| 41 | 41 | function action_spip_image_effacer_dist($arg) { |
| 42 | 42 | |
| 43 | - if (!strstr($arg, "..")) |
|
| 44 | - spip_unlink(_DIR_LOGOS . $arg); |
|
| 43 | + if (!strstr($arg, "..")) |
|
| 44 | + spip_unlink(_DIR_LOGOS . $arg); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | // |
@@ -52,80 +52,80 @@ discard block |
||
| 52 | 52 | // $dest = arton12.xxx |
| 53 | 53 | // http://doc.spip.org/@action_spip_image_ajouter_dist |
| 54 | 54 | function action_spip_image_ajouter_dist($arg,$sousaction2,$source,$return=false) { |
| 55 | - global $formats_logos; |
|
| 55 | + global $formats_logos; |
|
| 56 | 56 | |
| 57 | - include_spip('inc/documents'); |
|
| 58 | - if (!$sousaction2) { |
|
| 59 | - if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES']; |
|
| 60 | - $source = (is_array($_FILES) ? array_pop($_FILES) : ""); |
|
| 61 | - } |
|
| 62 | - $erreur = ""; |
|
| 63 | - if (!$source) |
|
| 64 | - spip_log("spip_image_ajouter : source inconnue"); |
|
| 65 | - else { |
|
| 66 | - $f =_DIR_LOGOS . $arg . '.tmp'; |
|
| 57 | + include_spip('inc/documents'); |
|
| 58 | + if (!$sousaction2) { |
|
| 59 | + if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES']; |
|
| 60 | + $source = (is_array($_FILES) ? array_pop($_FILES) : ""); |
|
| 61 | + } |
|
| 62 | + $erreur = ""; |
|
| 63 | + if (!$source) |
|
| 64 | + spip_log("spip_image_ajouter : source inconnue"); |
|
| 65 | + else { |
|
| 66 | + $f =_DIR_LOGOS . $arg . '.tmp'; |
|
| 67 | 67 | |
| 68 | - if (!is_array($source)) |
|
| 69 | - // fichier dans upload/ |
|
| 70 | - $source = @copy(determine_upload() . $source, $f); |
|
| 71 | - else { |
|
| 72 | - // Intercepter une erreur a l'envoi |
|
| 73 | - if ($erreur = check_upload_error($source['error'],"",$return)) |
|
| 74 | - $source =""; |
|
| 75 | - else |
|
| 76 | - // analyse le type de l'image (on ne fait pas confiance au nom de |
|
| 77 | - // fichier envoye par le browser : pour les Macs c'est plus sur) |
|
| 68 | + if (!is_array($source)) |
|
| 69 | + // fichier dans upload/ |
|
| 70 | + $source = @copy(determine_upload() . $source, $f); |
|
| 71 | + else { |
|
| 72 | + // Intercepter une erreur a l'envoi |
|
| 73 | + if ($erreur = check_upload_error($source['error'],"",$return)) |
|
| 74 | + $source =""; |
|
| 75 | + else |
|
| 76 | + // analyse le type de l'image (on ne fait pas confiance au nom de |
|
| 77 | + // fichier envoye par le browser : pour les Macs c'est plus sur) |
|
| 78 | 78 | |
| 79 | - $source = deplacer_fichier_upload($source['tmp_name'], $f); |
|
| 80 | - } |
|
| 81 | - if (!$source) |
|
| 82 | - spip_log("pb de copie pour $f"); |
|
| 83 | - } |
|
| 84 | - if ($source AND $f) { |
|
| 85 | - $size = @getimagesize($f); |
|
| 86 | - $type = !$size ? '': ($size[2] > 3 ? '' : $formats_logos[$size[2]-1]); |
|
| 87 | - if ($type) { |
|
| 88 | - $poids = filesize($f); |
|
| 79 | + $source = deplacer_fichier_upload($source['tmp_name'], $f); |
|
| 80 | + } |
|
| 81 | + if (!$source) |
|
| 82 | + spip_log("pb de copie pour $f"); |
|
| 83 | + } |
|
| 84 | + if ($source AND $f) { |
|
| 85 | + $size = @getimagesize($f); |
|
| 86 | + $type = !$size ? '': ($size[2] > 3 ? '' : $formats_logos[$size[2]-1]); |
|
| 87 | + if ($type) { |
|
| 88 | + $poids = filesize($f); |
|
| 89 | 89 | |
| 90 | - if (_LOGO_MAX_SIZE > 0 |
|
| 91 | - AND $poids > _LOGO_MAX_SIZE*1024) { |
|
| 92 | - spip_unlink ($f); |
|
| 93 | - $erreur = _T('info_logo_max_poids', |
|
| 94 | - array('maxi' => taille_en_octets(_LOGO_MAX_SIZE*1024), |
|
| 95 | - 'actuel' => taille_en_octets($poids))); |
|
| 96 | - } |
|
| 90 | + if (_LOGO_MAX_SIZE > 0 |
|
| 91 | + AND $poids > _LOGO_MAX_SIZE*1024) { |
|
| 92 | + spip_unlink ($f); |
|
| 93 | + $erreur = _T('info_logo_max_poids', |
|
| 94 | + array('maxi' => taille_en_octets(_LOGO_MAX_SIZE*1024), |
|
| 95 | + 'actuel' => taille_en_octets($poids))); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - elseif (_LOGO_MAX_WIDTH * _LOGO_MAX_HEIGHT |
|
| 99 | - AND ($size[0] > _LOGO_MAX_WIDTH |
|
| 100 | - OR $size[1] > _LOGO_MAX_HEIGHT)) { |
|
| 101 | - spip_unlink ($f); |
|
| 102 | - $erreur = _T('info_logo_max_poids', |
|
| 103 | - array( |
|
| 104 | - 'maxi' => |
|
| 105 | - _T('info_largeur_vignette', |
|
| 106 | - array('largeur_vignette' => _LOGO_MAX_WIDTH, |
|
| 107 | - 'hauteur_vignette' => _LOGO_MAX_HEIGHT)), |
|
| 108 | - 'actuel' => |
|
| 109 | - _T('info_largeur_vignette', |
|
| 110 | - array('largeur_vignette' => $size[0], |
|
| 111 | - 'hauteur_vignette' => $size[1])) |
|
| 112 | - )); |
|
| 113 | - } |
|
| 114 | - else |
|
| 115 | - @rename ($f, _DIR_LOGOS . $arg . ".$type"); |
|
| 116 | - } |
|
| 117 | - else { |
|
| 118 | - spip_unlink ($f); |
|
| 119 | - $erreur = _T('info_logo_format_interdit', |
|
| 120 | - array('formats' => join(', ', $formats_logos))); |
|
| 121 | - } |
|
| 98 | + elseif (_LOGO_MAX_WIDTH * _LOGO_MAX_HEIGHT |
|
| 99 | + AND ($size[0] > _LOGO_MAX_WIDTH |
|
| 100 | + OR $size[1] > _LOGO_MAX_HEIGHT)) { |
|
| 101 | + spip_unlink ($f); |
|
| 102 | + $erreur = _T('info_logo_max_poids', |
|
| 103 | + array( |
|
| 104 | + 'maxi' => |
|
| 105 | + _T('info_largeur_vignette', |
|
| 106 | + array('largeur_vignette' => _LOGO_MAX_WIDTH, |
|
| 107 | + 'hauteur_vignette' => _LOGO_MAX_HEIGHT)), |
|
| 108 | + 'actuel' => |
|
| 109 | + _T('info_largeur_vignette', |
|
| 110 | + array('largeur_vignette' => $size[0], |
|
| 111 | + 'hauteur_vignette' => $size[1])) |
|
| 112 | + )); |
|
| 113 | + } |
|
| 114 | + else |
|
| 115 | + @rename ($f, _DIR_LOGOS . $arg . ".$type"); |
|
| 116 | + } |
|
| 117 | + else { |
|
| 118 | + spip_unlink ($f); |
|
| 119 | + $erreur = _T('info_logo_format_interdit', |
|
| 120 | + array('formats' => join(', ', $formats_logos))); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - } |
|
| 124 | - if ($erreur){ |
|
| 125 | - if ($return) |
|
| 126 | - return $erreur; |
|
| 127 | - else |
|
| 128 | - check_upload_error(6,$erreur); |
|
| 129 | - } |
|
| 123 | + } |
|
| 124 | + if ($erreur){ |
|
| 125 | + if ($return) |
|
| 126 | + return $erreur; |
|
| 127 | + else |
|
| 128 | + check_upload_error(6,$erreur); |
|
| 129 | + } |
|
| 130 | 130 | } |
| 131 | 131 | ?> |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | 19 | function action_purger_queue_dist(){ |
| 20 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 21 | - $securiser_action(); |
|
| 20 | + $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 21 | + $securiser_action(); |
|
| 22 | 22 | |
| 23 | - if (autoriser('purger','queue')){ |
|
| 24 | - include_spip('inc/queue'); |
|
| 25 | - queue_purger(); |
|
| 26 | - } |
|
| 23 | + if (autoriser('purger','queue')){ |
|
| 24 | + include_spip('inc/queue'); |
|
| 25 | + queue_purger(); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | |
@@ -20,44 +20,44 @@ discard block |
||
| 20 | 20 | * @param string|null $arg |
| 21 | 21 | */ |
| 22 | 22 | function action_calculer_taille_cache_dist($arg=null){ |
| 23 | - if (is_null($arg)){ |
|
| 24 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 25 | - $arg = $securiser_action(); |
|
| 26 | - } |
|
| 27 | - include_spip('inc/filtres'); |
|
| 23 | + if (is_null($arg)){ |
|
| 24 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 25 | + $arg = $securiser_action(); |
|
| 26 | + } |
|
| 27 | + include_spip('inc/filtres'); |
|
| 28 | 28 | |
| 29 | - if ($arg=='images'){ |
|
| 30 | - $taille = calculer_taille_dossier(_DIR_VAR); |
|
| 31 | - $res = _T('ecrire:taille_cache_image', |
|
| 32 | - array( |
|
| 33 | - 'dir' => joli_repertoire(_DIR_VAR), |
|
| 34 | - 'taille' => "<b>".(taille_en_octets($taille) > 0 ? taille_en_octets($taille) : "0 octet")."</b>" |
|
| 35 | - ) |
|
| 36 | - ); |
|
| 37 | - } |
|
| 38 | - else { |
|
| 39 | - include_spip('inc/invalideur'); |
|
| 40 | - $taille = |
|
| 41 | - calculer_taille_dossier(_DIR_CACHE_XML) |
|
| 42 | - +calculer_taille_dossier(_DIR_CACHE.'skel/') |
|
| 43 | - +calculer_taille_dossier(_DIR_CACHE.'wheels/') |
|
| 44 | - +calculer_taille_dossier(_DIR_CACHE.'contextes/') |
|
| 45 | - ; |
|
| 46 | - $taille += intval(taille_du_cache()); |
|
| 47 | - if ($taille<=150000){ |
|
| 48 | - $res = _T('taille_cache_vide'); |
|
| 49 | - } |
|
| 50 | - elseif ($taille<=1024*1024){ |
|
| 51 | - $res = _T('taille_cache_moins_de',array('octets'=>taille_en_octets(1024*1024))); |
|
| 52 | - } |
|
| 53 | - else { |
|
| 54 | - $res = _T('taille_cache_octets',array('octets'=>taille_en_octets($taille))); |
|
| 55 | - } |
|
| 56 | - $res = "<b>$res</b>"; |
|
| 57 | - } |
|
| 29 | + if ($arg=='images'){ |
|
| 30 | + $taille = calculer_taille_dossier(_DIR_VAR); |
|
| 31 | + $res = _T('ecrire:taille_cache_image', |
|
| 32 | + array( |
|
| 33 | + 'dir' => joli_repertoire(_DIR_VAR), |
|
| 34 | + 'taille' => "<b>".(taille_en_octets($taille) > 0 ? taille_en_octets($taille) : "0 octet")."</b>" |
|
| 35 | + ) |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | + else { |
|
| 39 | + include_spip('inc/invalideur'); |
|
| 40 | + $taille = |
|
| 41 | + calculer_taille_dossier(_DIR_CACHE_XML) |
|
| 42 | + +calculer_taille_dossier(_DIR_CACHE.'skel/') |
|
| 43 | + +calculer_taille_dossier(_DIR_CACHE.'wheels/') |
|
| 44 | + +calculer_taille_dossier(_DIR_CACHE.'contextes/') |
|
| 45 | + ; |
|
| 46 | + $taille += intval(taille_du_cache()); |
|
| 47 | + if ($taille<=150000){ |
|
| 48 | + $res = _T('taille_cache_vide'); |
|
| 49 | + } |
|
| 50 | + elseif ($taille<=1024*1024){ |
|
| 51 | + $res = _T('taille_cache_moins_de',array('octets'=>taille_en_octets(1024*1024))); |
|
| 52 | + } |
|
| 53 | + else { |
|
| 54 | + $res = _T('taille_cache_octets',array('octets'=>taille_en_octets($taille))); |
|
| 55 | + } |
|
| 56 | + $res = "<b>$res</b>"; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $res = "<p>$res</p>"; |
|
| 60 | - ajax_retour($res); |
|
| 59 | + $res = "<p>$res</p>"; |
|
| 60 | + ajax_retour($res); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -70,20 +70,20 @@ discard block |
||
| 70 | 70 | * @return int |
| 71 | 71 | */ |
| 72 | 72 | function calculer_taille_dossier ($dir) { |
| 73 | - $handle = @opendir($dir); |
|
| 74 | - if (!$handle) return 0; |
|
| 75 | - $taille = 0; |
|
| 76 | - while (($fichier = @readdir($handle)) !== false) { |
|
| 77 | - // Eviter ".", "..", ".htaccess", etc. |
|
| 78 | - if ($fichier[0] == '.') continue; |
|
| 79 | - if (is_file($d = "$dir/$fichier")) { |
|
| 80 | - $taille += filesize($d); |
|
| 81 | - } |
|
| 82 | - else if (is_dir($d)) |
|
| 83 | - $taille += calculer_taille_dossier($d); |
|
| 84 | - } |
|
| 85 | - closedir($handle); |
|
| 86 | - return $taille; |
|
| 73 | + $handle = @opendir($dir); |
|
| 74 | + if (!$handle) return 0; |
|
| 75 | + $taille = 0; |
|
| 76 | + while (($fichier = @readdir($handle)) !== false) { |
|
| 77 | + // Eviter ".", "..", ".htaccess", etc. |
|
| 78 | + if ($fichier[0] == '.') continue; |
|
| 79 | + if (is_file($d = "$dir/$fichier")) { |
|
| 80 | + $taille += filesize($d); |
|
| 81 | + } |
|
| 82 | + else if (is_dir($d)) |
|
| 83 | + $taille += calculer_taille_dossier($d); |
|
| 84 | + } |
|
| 85 | + closedir($handle); |
|
| 86 | + return $taille; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | ?> |
| 90 | 90 | \ No newline at end of file |