コード例 #1
0
 function contenidos()
 {
     global $referencia, $urlOK, $urlNOK, $__BD, $dimThum, $dimSuperThum, $dim, $dimMedX, $dimMedY;
     $codigo = '';
     $pathNor = "../catalogo/img_normal/" . $referencia;
     $pathMed = "../catalogo/img_mediana/" . $referencia;
     $pathThum = "../catalogo/img_thumb/" . $referencia;
     $pathSuperThum = "../catalogo/img_superthumb/" . $referencia;
     if (!file_exists($pathNor)) {
         mkdir($pathNor);
     }
     if (!file_exists($pathMed)) {
         mkdir($pathMed);
     }
     if (!file_exists($pathThum)) {
         mkdir($pathThum);
     }
     if (!file_exists($pathSuperThum)) {
         mkdir($pathSuperThum);
     }
     // we first include the upload class, as we will need it here to deal with the uploaded file
     if (!isset($_POST['action'])) {
         header($urlOK);
         exit;
     }
     $nomFichs = $this->leerDir($pathNor);
     $paso = 1;
     if ($nomFichs) {
         $paso += count($nomFichs);
     }
     $files = array();
     foreach ($_FILES['my_field'] as $k => $l) {
         foreach ($l as $i => $v) {
             if (!array_key_exists($i, $files)) {
                 $files[$i] = array();
             }
             $files[$i][$k] = $v;
         }
     }
     // now we can loop through $files, and feed each element to the class
     $ordenSQL = "select max(id) from articulosfotos";
     $orden = $__BD->db_valor($ordenSQL);
     $orden++;
     foreach ($files as $file) {
         $handle = new upload_eStoreQ($file);
         if (!$handle->uploaded) {
             continue;
         }
         $orden++;
         $handle->image_x = $dim;
         $handle->image_y = $dim;
         $handle->image_resize = true;
         $handle->image_ratio_no_zoom_in = true;
         $handle->file_new_name_body = $orden;
         // Foto normal
         $handle->Process($pathNor);
         // Mediana
         $handle->image_x = $dimMedX;
         $handle->image_y = $dimMedY;
         $handle->image_resize = true;
         $handle->image_ratio_no_zoom_in = true;
         $handle->file_new_name_body = $orden;
         $handle->Process($pathMed);
         // Thumb
         $handle->image_x = $dimThum;
         $handle->image_y = $dimThum;
         $handle->image_resize = true;
         $handle->image_ratio = true;
         $handle->file_new_name_body = $orden;
         $handle->Process($pathThum);
         // SuperThumb
         $handle->image_x = $dimSuperThum;
         $handle->image_y = $dimSuperThum;
         $handle->image_resize = true;
         $handle->image_ratio = true;
         $handle->file_new_name_body = $orden;
         $handle->Process($pathSuperThum);
         if ($handle->processed) {
             $nomFich = $handle->file_dst_name;
             $ordenSQL = "insert into articulosfotos(referencia, nomfichero, orden, id) values ('{$referencia}', '{$nomFich}', {$orden}, {$orden})";
             $result = $__BD->db_query($ordenSQL);
             header($urlOK);
         } else {
             header($urlNOK);
         }
     }
 }
コード例 #2
0
ファイル: im_index.php プロジェクト: kailIII/eneboo-ecommerce
 /** Pasa las imagenes viejas al nuevo sistema
  */
 function actualizarObsoletos()
 {
     global $__BD;
     $codigo = '';
     $ordenSQL = "select count(id) from articulosfotos";
     if ($__BD->db_valor($ordenSQL)) {
         return;
     }
     $ordenSQL = "select piximages from opcionestv";
     $dimThum = $__BD->db_valor($ordenSQL);
     $dimSuperThum = 60;
     $paso = 0;
     $ordenSQL = "select referencia,tipoimagen from articulos order by referencia";
     $result = $__BD->db_query($ordenSQL);
     while ($row = $__BD->db_fetch_array($result)) {
         $referencia = $row["referencia"];
         $ext = $row["tipoimagen"];
         $pathNor = "../catalogo/img_normal/" . $referencia;
         $pathThum = "../catalogo/img_thumb/" . $referencia;
         $pathSuperThum = "../catalogo/img_superthumb/" . $referencia;
         if (!file_exists($pathNor)) {
             mkdir($pathNor);
         }
         if (!file_exists($pathThum)) {
             mkdir($pathThum);
         }
         if (!file_exists($pathSuperThum)) {
             mkdir($pathSuperThum);
         }
         $nomFich = $referencia . '.' . $ext;
         $imgNor = "../catalogo/img_normal/" . $nomFich;
         if (!file_exists($imgNor)) {
             $nomFich = $referencia . '.jpg';
             $imgNor = "../catalogo/img_normal/" . $nomFich;
         }
         if (!file_exists($imgNor)) {
             continue;
         }
         $ordenSQL = "select id from articulosfotos where referencia='{$referencia}' and nomfichero='{$nomFich}'";
         if ($__BD->db_valor($ordenSQL)) {
             continue;
         }
         $handle = new upload_eStoreQ($imgNor);
         // Foto normal
         $handle->Process($pathNor);
         // Thumb
         $handle->image_x = $dimThum;
         $handle->image_y = $dimThum;
         $handle->image_resize = true;
         $handle->image_ratio = true;
         $handle->file_new_name_body = $orden;
         $handle->Process($pathThum);
         // SuperThumb
         $handle->image_x = $dimSuperThum;
         $handle->image_y = $dimSuperThum;
         $handle->image_resize = true;
         $handle->image_ratio = true;
         $handle->file_new_name_body = $orden;
         $handle->Process($pathSuperThum);
         if ($handle->processed) {
             $ordenSQL = "update articulosfotos set orden = orden + 1 where referencia = '{$referencia}'";
             $__BD->db_query($ordenSQL);
             $ordenSQL = "insert into articulosfotos(referencia, nomfichero, orden) values ('{$referencia}', '{$nomFich}', 1)";
             $__BD->db_query($ordenSQL);
             $codigo .= "Fichero <b>{$nomFich}</b> procesado<br/>";
         } else {
             $codigo .= '<p>Error: ' . $handle->error . ' ' . $handle->file_dst_name;
         }
         $paso++;
     }
 }