Exemplo n.º 1
0
function _make_image($tmp_img, $image_type, $extention, $opt)
{
    $resize = $opt['resize'];
    $opt_list = $opt['list'];
    if (!$opt_list) {
        $opt_list = array($opt);
    }
    $ret = array();
    foreach ($opt_list as $opt_) {
        if ($resize) {
            $content = image_file_resize($tmp_img, $image_type, $opt_['crop'], $opt_['width'], $opt_['height']);
        } else {
            $content = file_get_contents($tmp_img);
        }
        $file_name = uniqid() . '.' . $extention;
        $ret[] = write_upload($content, $file_name);
    }
    return count($ret) === 1 ? reset($ret) : $ret;
}
Exemplo n.º 2
0
 $colorst7 = '#ffffff';
 $colorst8 = '#ffffff';
 $colorst9 = '#FF9900';
 $colorst10 = '#000000';
 entete();
 menu();
 require 'install/etape_8.php';
 if (!isset($op)) {
     $op = 'etape_8';
 }
 switch ($op) {
     case 'write_upload':
         global $stage, $langue, $stage8_ok;
         include 'config.php';
         //       mysql_connex();
         write_upload($new_max_size, $new_DOCUMENTROOT, $new_autorise_upload_p, $new_racine, $new_rep_upload, $new_rep_cache, $new_rep_log, $new_url_upload);
         echo '
    <h3>' . ins_translate("Configuration du module UPload") . '</h3>';
         if ($stage8_ok == 1) {
             $msg = 'Le fichier de configuration a été écrit avec succès !';
         } elseif ($stage8_ok == 0) {
             $msg = "Le fichier de configuration n'a pas pu être modifié. Vérifiez les droits d'accès au fichier 'config.php', puis réessayez à nouveau.";
         }
         echo '<form name="next" method="post" action="install.php">
          ' . ins_translate($msg);
         if ($stage8_ok == 1) {
             echo '
             <input type="hidden" name="langue" value="' . $langue . '" />
             <input type="hidden" name="stage" value="9" />
             <br /><br />
             <input type="submit" class="btn btn-secondary" value="' . ins_translate(" Etape suivante ") . '" />';
Exemplo n.º 3
0
/**
 * main function
 * @param type $image like $_FILE['xx']
 * @param type $opt resize crop width height
 * @return string url of the final img
 * @throws Exception
 */
function make_image($image, $opt = array())
{
    // deault option
    $opt = array_merge(array('crop' => 0, 'resize' => 0, 'width' => 50, 'height' => 50, 'list' => null), $opt);
    $arr = explode('/', $image['type']);
    $file_type = reset($arr);
    $image_type = end($arr);
    if ($file_type == 'image') {
        $extention = file_ext($image['name']);
        $tmp_img = $image['tmp_name'];
        $resize = $opt['resize'];
        $ret_list = $opt['list'];
        if ($ret_list) {
            $ret = array();
            foreach ($ret_list as $opt_) {
                if ($resize) {
                    image_file_resize($tmp_img, $image_type, $opt_['crop'], $opt_['width'], $opt_['height']);
                }
                $content = file_get_contents($tmp_img);
                $file_name = uniqid() . '.' . $extention;
                $ret[] = write_upload($content, $file_name);
            }
            return $ret;
        } else {
            if ($resize) {
                image_file_resize($tmp_img, $image_type, $opt['crop'], $opt['width'], $opt['height']);
            }
            $content = file_get_contents($tmp_img);
            $file_name = uniqid() . '.' . $extention;
            return write_upload($content, $file_name);
        }
    } else {
        // maybe throw??
        return '';
    }
}