Exemple #1
0
/**
 * L'entree par l'action ne sert plus qu'a une retro compat eventuelle
 * le #FORMULAIRE_EDITER_LOGO utilise action_spip_image_ajouter_dist
 */
function action_iconifier_dist()
{
    include_spip('inc/actions');
    $securiser_action = charger_fonction('securiser_action', 'inc');
    $arg = $securiser_action();
    $iframe_redirect = _request('iframe_redirect');
    $arg = rawurldecode($arg);
    if (!preg_match(',^-?\\d*(\\D)(.*)$,', $arg, $r)) {
        spip_log("action iconifier: {$arg} pas compris");
    } elseif ($r[1] == '+') {
        action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source'));
    } else {
        action_spip_image_effacer_dist($r[2]);
    }
    if (_request("iframe") == 'iframe') {
        $redirect = urldecode($iframe_redirect) . "&iframe=iframe";
        redirige_par_entete(urldecode($redirect));
    }
}
function logo_revision($id, $file, $type, $ref)
{
    $chercher_logo = charger_fonction('chercher_logo', 'inc');
    $_id_objet = id_table_objet($type);
    // Chargement d'un nouveau logo ?
    if ($file['logo']) {
        define('FILE_UPLOAD', true);
        // message pour crayons_json_export :(
        if (include_spip("action/editer_logo") and function_exists("logo_modifier")) {
            logo_modifier($type, $id, "on", $file['logo']);
        } else {
            // supprimer l'ancien logo
            $on = $chercher_logo($id, $_id_objet, 'on');
            if ($on) {
                @unlink($on[0]);
            }
            // ajouter le nouveau
            include_spip('action/iconifier');
            action_spip_image_ajouter_dist(type_du_logo($_id_objet) . 'on' . $id, false, false);
            // beurk
        }
    } else {
        // Suppression du logo ?
        if ($wid = array_pop($ref) and $_POST['content_' . $wid . '_logo_supprimer'] == 'on') {
            if (include_spip("action/editer_logo") and function_exists("logo_supprimer")) {
                logo_supprimer($type, $id, "on");
            } else {
                if ($on = $chercher_logo($id, $_id_objet, 'on')) {
                    @unlink($on[0]);
                }
            }
        }
    }
    // Reduire le logo ?
    if (is_array($cfg = @unserialize($GLOBALS['meta']['crayons'])) and $max = intval($cfg['reduire_logo'])) {
        $on = $chercher_logo($id, $_id_objet, 'on');
        include_spip('inc/filtres');
        @copy($on[0], $temp = _DIR_VAR . 'tmp' . rand(0, 999) . '.' . $on[3]);
        $img1 = filtrer('image_reduire', $temp, $max);
        $img2 = preg_replace(',[?].*,', '', extraire_attribut($img1, 'src'));
        if (@file_exists($img2) and $img2 != $temp) {
            if (include_spip("action/editer_logo") and function_exists("logo_modifier")) {
                logo_modifier($type, $id, "on", $img2);
            } else {
                @unlink($on[0]);
                $dest = $on[1] . $on[2] . '.' . preg_replace(',^.*\\.(gif|jpg|png)$,', '\\1', $img2);
                @rename($img2, $dest);
            }
        }
        @unlink($temp);
    }
    return true;
}