3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2011 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined('_ECRIRE_INC_VERSION')) return;
15 // http://doc.spip.org/@action_iconifier_dist
16 function action_iconifier_dist()
18 include_spip('inc/actions');
19 $securiser_action = charger_fonction('securiser_action', 'inc');
20 $arg = $securiser_action();
21 $iframe_redirect = _request('iframe_redirect');
23 $arg = rawurldecode($arg);
25 if (!preg_match(',^-?\d*(\D)(.*)$,',$arg, $r))
26 spip_log("action iconifier: $arg pas compris");
28 action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source'));
29 else action_spip_image_effacer_dist($r[2]);
31 if(_request("iframe") == 'iframe') {
32 $redirect = urldecode($iframe_redirect)."&iframe=iframe";
33 redirige_par_entete(urldecode($redirect));
37 // http://doc.spip.org/@action_spip_image_effacer_dist
38 function action_spip_image_effacer_dist($arg) {
40 if (!strstr($arg, ".."))
41 spip_unlink(_DIR_LOGOS
. $arg);
48 // $source = $_FILES[0]
49 // $dest = arton12.xxx
50 // http://doc.spip.org/@action_spip_image_ajouter_dist
51 function action_spip_image_ajouter_dist($arg,$sousaction2,$source) {
52 global $formats_logos;
54 include_spip('inc/getdocument');
56 if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES'];
57 $source = (is_array($_FILES) ?
array_pop($_FILES) : "");
60 $f =_DIR_LOGOS
. $arg . '.tmp';
62 if (!is_array($source))
63 // fichier dans upload/
64 $source = @copy
(determine_upload() . $source, $f);
66 // Intercepter une erreur a l'envoi
67 if (check_upload_error($source['error']))
70 // analyse le type de l'image (on ne fait pas confiance au nom de
71 // fichier envoye par le browser : pour les Macs c'est plus sur)
73 $source = deplacer_fichier_upload($source['tmp_name'], $f);
77 spip_log("pb de copie pour $f");
79 $size = @getimagesize
($f);
80 $type = !$size ?
'': ($size[2] > 3 ?
'' : $formats_logos[$size[2]-1]);
82 $poids = filesize($f);
84 if (_LOGO_MAX_SIZE
> 0
85 AND $poids > _LOGO_MAX_SIZE
*1024) {
88 _T('info_logo_max_poids',
89 array('maxi' => taille_en_octets(_LOGO_MAX_SIZE
*1024),
90 'actuel' => taille_en_octets($poids))));
93 if (_LOGO_MAX_WIDTH
* _LOGO_MAX_HEIGHT
94 AND ($size[0] > _LOGO_MAX_WIDTH
95 OR $size[1] > _LOGO_MAX_HEIGHT
)) {
98 _T('info_logo_max_taille',
101 _T('info_largeur_vignette',
102 array('largeur_vignette' => _LOGO_MAX_WIDTH
,
103 'hauteur_vignette' => _LOGO_MAX_HEIGHT
)),
105 _T('info_largeur_vignette',
106 array('largeur_vignette' => $size[0],
107 'hauteur_vignette' => $size[1]))
110 @rename
($f, _DIR_LOGOS
. $arg . ".$type");
114 check_upload_error(6,_T('info_logo_format_interdit',
115 array('formats' => join(', ', $formats_logos))));