3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2016 *
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;
16 * L'entree par l'action ne sert plus qu'a une retro compat eventuelle
17 * le #FORMULAIRE_EDITER_LOGO utilise action_spip_image_ajouter_dist
19 function action_iconifier_dist()
21 include_spip('inc/actions');
22 $securiser_action = charger_fonction('securiser_action', 'inc');
23 $arg = $securiser_action();
24 $iframe_redirect = _request('iframe_redirect');
26 $arg = rawurldecode($arg);
28 if (!preg_match(',^-?\d*(\D)(.*)$,',$arg, $r))
29 spip_log("action iconifier: $arg pas compris");
31 action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source'));
32 else action_spip_image_effacer_dist($r[2]);
34 if(_request("iframe") == 'iframe') {
35 $redirect = urldecode($iframe_redirect)."&iframe=iframe";
36 redirige_par_entete(urldecode($redirect));
40 // http://doc.spip.org/@action_spip_image_effacer_dist
41 function action_spip_image_effacer_dist($arg) {
43 if (!strstr($arg, ".."))
44 spip_unlink(_DIR_LOGOS
. $arg);
51 // $source = $_FILES[0]
52 // $dest = arton12.xxx
53 // http://doc.spip.org/@action_spip_image_ajouter_dist
54 function action_spip_image_ajouter_dist($arg,$sousaction2,$source,$return=false) {
55 global $formats_logos;
57 include_spip('inc/documents');
59 if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES'];
60 $source = (is_array($_FILES) ?
array_pop($_FILES) : "");
64 spip_log("spip_image_ajouter : source inconnue");
66 $f =_DIR_LOGOS
. $arg . '.tmp';
68 if (!is_array($source))
69 // fichier dans upload/
70 $source = @copy
(determine_upload() . $source, $f);
72 // Intercepter une erreur a l'envoi
73 if ($erreur = check_upload_error($source['error'],"",$return))
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)
79 $source = deplacer_fichier_upload($source['tmp_name'], $f);
82 spip_log("pb de copie pour $f");
85 $size = @getimagesize
($f);
86 $type = !$size ?
'': ($size[2] > 3 ?
'' : $formats_logos[$size[2]-1]);
88 $poids = filesize($f);
90 if (_LOGO_MAX_SIZE
> 0
91 AND $poids > _LOGO_MAX_SIZE
*1024) {
93 $erreur = _T('info_logo_max_poids',
94 array('maxi' => taille_en_octets(_LOGO_MAX_SIZE
*1024),
95 'actuel' => taille_en_octets($poids)));
98 elseif (_LOGO_MAX_WIDTH
* _LOGO_MAX_HEIGHT
99 AND ($size[0] > _LOGO_MAX_WIDTH
100 OR $size[1] > _LOGO_MAX_HEIGHT
)) {
102 $erreur = _T('info_logo_max_poids',
105 _T('info_largeur_vignette',
106 array('largeur_vignette' => _LOGO_MAX_WIDTH
,
107 'hauteur_vignette' => _LOGO_MAX_HEIGHT
)),
109 _T('info_largeur_vignette',
110 array('largeur_vignette' => $size[0],
111 'hauteur_vignette' => $size[1]))
115 @rename
($f, _DIR_LOGOS
. $arg . ".$type");
119 $erreur = _T('info_logo_format_interdit',
120 array('formats' => join(', ', $formats_logos)));
128 check_upload_error(6,$erreur);