Exemplo n.º 1
0
             $needs_thumb = true;
         } elseif (defined('THUMB_EXACT_W') and defined('THUMB_EXACT_H')) {
             $thumb1 = $uplo->save_thumbnail(THUMB_EXACT_W, THUMB_EXACT_H, 'shrink_to_size');
             $needs_thumb = true;
         }
         if ($needs_thumb && empty($thumb1)) {
             $thumb1 = $newfilename;
         }
         if (PEAR::isError($thumb1)) {
             $errs[] = $thumb1->getMessage();
         } else {
             $vals['system_location'] = CSHOP_MEDIA_URLPATH;
             $vals['filename_large'] = $newfilename;
             $vals['dims_large'] = $img_dims;
             $vals['filename_thumb'] = $thumb1;
             $vals['dims_thumb'] = $uplo->get_thumb_dims();
             $vals['mime_type'] = $uplo->get_filetype();
             if (isset($zoom_file)) {
                 $vals['filename_zoom'] = basename($zoom_file);
             }
         }
     }
 }
 if (!count($errs)) {
     if ($ACTION == OP_ADD) {
         $vals['id'] = $pdb->nextId($tablename);
         $res = $pdb->autoExecute($tablename, $vals, DB_AUTOQUERY_INSERT);
     } elseif ($ACTION == OP_EDIT) {
         $where = sprintf("id = %d", $reqid);
         $res = $pdb->autoExecute($tablename, $vals, DB_AUTOQUERY_UPDATE, $where);
     }
Exemplo n.º 2
0
         $res = $uplo->save_upload();
         if (PEAR::isError($res)) {
             $errs[] = $res->getMessage();
         } else {
             // get the name of the new file
             $newfilename = $uplo->get_newname();
             // vals to be put in DB
             $upfiles[$upfile] = array('sFilename' => $newfilename, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i'), 'img_dims' => $uplo->get_img_dims());
             if ($upfile == 'imageid') {
                 // create a thumbnail right here:
                 $thumb1 = $uplo->save_thumbnail(THUMB_MAX_W, THUMB_MAX_H);
                 if (PEAR::isError($thumb1)) {
                     $errs[] = $thumb1->getMessage();
                 } else {
                     // another upfile for the thumbnail image
                     $upfiles['image_thumbid'] = array('sFilename' => $thumb1, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i'), 'img_dims' => $uplo->get_thumb_dims());
                 }
             }
         }
     }
 }
 $imgcount = 0;
 /** try to insert or update image info to DB table media_prod **/
 foreach ($upfiles as $upfile => $img_vals) {
     if (count($img_vals)) {
         $imgcount++;
         $oldimg = null;
         $sql = sprintf("SELECT %s FROM cm_products WHERE id = %d", $upfile, $productid);
         if ($oldfileid = $pdb->getOne($sql)) {
             $sql = sprintf("SELECT id, sFilename FROM media_prod \n                                    WHERE id = %d", $oldfileid);
             $oldimg = $pdb->getRow($sql);