예제 #1
0
 if ($errs = $mosh->check_form($colmap)) {
     // handled below
 } else {
     $vals = $mosh->get_form_vals($colmap);
     /** get list of all file upload fields from colmap **/
     $upfiles = array();
     foreach ($colmap as $k => $params) {
         if ($params[1] == 'image_upload' or $params[1] == 'file') {
             $upfiles[$k] = array();
         }
     }
     /** are there any actual files coming in? if so process *********************************/
     $uplo_count = 0;
     if (count($upfiles)) {
         foreach (array_keys($upfiles) as $upfile) {
             $uplo = new uploadable($upfile);
             if (!$uplo->is_uploaded_file()) {
                 #unset($upfiles[$upfile]);
             } else {
                 // we got one - use $uplo to check it and save it and create DB vals as needed
                 $uplo->preserve_original_name = true;
                 $uplo->setErrorHandling(PEAR_ERROR_RETURN);
                 // tell $uplo what kind of image we expect and where to put it:
                 $uplo->params(array('path' => CSHOP_MEDIA_FULLPATH, 'ws_path' => CSHOP_MEDIA_URLPATH) + $colmap[$upfile][3]);
                 // set other possible params for uplo from the colmap attribs section [3]
                 // todo something better */
                 $res = $uplo->save_upload();
                 if (PEAR::isError($res)) {
                     $errs[] = $res->getMessage();
                 } else {
                     // get the name of the new file
예제 #2
0
 $vals = array();
 $img_vals = array();
 if ($errs = $mosh->check_form($colmap)) {
     // handled below
 } else {
     $vals = $mosh->get_form_vals($colmap);
     /** get list of all file upload fields from colmap **/
     $upfiles = array();
     foreach ($colmap as $k => $params) {
         if ($params[1] == 'image_upload' or $params[1] == 'file') {
             $upfiles[$k] = array();
         }
     }
     /** process each uploaded image **/
     foreach (array_keys($upfiles) as $upfile) {
         $uplo = new uploadable("f_{$upfile}");
         if (!$uplo->is_uploaded_file()) {
             if ($ACTION == OP_ADD) {
                 // not req.
             }
         } else {
             // we got one - use $uplo to check it and save it and create DB vals as needed
             $uplo->unique_filename = true;
             $uplo->preserve_original_name = true;
             $uplo->setErrorHandling(PEAR_ERROR_RETURN);
             // tell $uplo what kind of image we expect and where to put it:
             $uplo->params(array('path' => CSHOP_MEDIA_FULLPATH, 'allowed' => 'web_images', 'ws_path' => CSHOP_MEDIA_URLPATH));
             $res = $uplo->save_upload();
             if (PEAR::isError($res)) {
                 $errs[] = $res->getMessage();
             } else {
예제 #3
0
        $res = $mdb->query($sql);
        while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
            if (empty($row['invid'])) {
                $counts['new_inv'] += $sth_inv->execute(array($mdb->nextID('cm_inventory'), $row['qty'], $row['sku'], $row['name'], sizecode($row['size']), sizecode(strtolower($row['color']))));
            } else {
                $counts['updated_inv'] += $sth_up->execute(array($row['qty'], $row['sku']));
            }
        }
        /* cleanup! */
        $mdb->query("DROP TABLE tmp_inv");
        $mdb->commit();
        $SHOWFORM = false;
        $DID_PROCESS = true;
    }
} elseif (isset($_POST['op_up'])) {
    $uplo = new uploadable('datafile');
    if (!$uplo->is_uploaded_file()) {
        $errs[] = "You must upload a data file to get started.";
    } else {
        $uplo->setErrorHandling(PEAR_ERROR_RETURN);
        $uplo->preserve_original_name = false;
        $uplo->params = array('path' => CSHOP_MEDIA_FULLPATH, 'ws_path' => CSHOP_MEDIA_URLPATH, 'fnamebase' => uniqid('inventory-data.000'));
        $res = $uplo->save_upload();
        if (PEAR::isError($res)) {
            $errs[] = $res->getMessage();
        } else {
            $newfilename = $uplo->get_newname();
            // get the name of the new file
            $fullpathfile = $uplo->fullPathtoFile;
            ini_set('auto_detect_line_endings', 1);
            if (!($fh = fopen($fullpathfile, "r"))) {
예제 #4
0
 $vals = array();
 $img_vals = array();
 if ($errs = $mosh->check_form($colmap)) {
     // handled below
 } else {
     $vals = $mosh->get_form_vals($colmap);
     /** get list of all file upload fields from colmap **/
     $upfiles = array();
     foreach ($colmap as $k => $params) {
         if ($params[1] == 'image_upload' or $params[1] == 'file') {
             $upfiles[$k] = array();
         }
     }
     /** process each uploaded image **/
     foreach (array_keys($upfiles) as $upfile) {
         $uplo = new uploadable("f_{$upfile}");
         if (!$uplo->is_uploaded_file()) {
             if ($ACTION == OP_ADD) {
                 // not req.
             }
         } else {
             // we got one - use $uplo to check it and save it and create DB vals as needed
             $uplo->unique_filename = true;
             $uplo->preserve_original_name = true;
             $uplo->setErrorHandling(PEAR_ERROR_RETURN);
             // tell $uplo what kind of image we expect and where to put it:
             $uplo->params($colmap[$upfile][3]);
             $res = $uplo->save_upload();
             if (PEAR::isError($res)) {
                 $errs[] = $res->getMessage();
             } else {
예제 #5
0
파일: store.media.php 프로젝트: sbeam/cshop
}
/** **/
if (!$productid) {
    trigger_error("productid was not passed", E_USER_ERROR);
}
$allowed_image_types = function_exists('imagecreatefromgif') ? 'web_images' : 'web_images_nogif';
$colmap = array('upfile' => array('Image', 'image_upload', null, array('allowed' => $allowed_image_types, 'maxdims' => IMG_MAX_DIMS, 'path' => CSHOP_MEDIA_FULLPATH, 'ws_path' => CSHOP_MEDIA_URLPATH), true), 'class' => array('Class', 'select', $CSHOP_MEDIA_CLASSES, null, false), 'colorways_id' => array('Colorway', 'select', array(), null, false), 'order_weight' => array('Order Weight', 'numeric', null, array('size' => 3), false));
/** POST rec'd, check valid, proc. upload and save if OK */
if (isset($_POST['f_op']) and ($ACTION == OP_ADD or $ACTION == OP_EDIT)) {
    $mosh = new mosh_tool();
    if ($errs = $mosh->check_form($colmap)) {
        // handled below
    } else {
        $vals = $mosh->get_form_vals($colmap);
        $vals['cm_products_id'] = $productid;
        $uplo = new uploadable("f_upfile");
        if (!$uplo->is_uploaded_file()) {
            if ($ACTION == OP_ADD) {
                $errs[] = 'You must upload image!';
            }
        } else {
            // we got one - use $uplo to check it and save it and create DB vals as needed
            $uplo->preserve_original_name = true;
            $uplo->setErrorHandling(PEAR_ERROR_RETURN);
            // tell $uplo what kind of image we expect and where to put it:
            $uplo->params = $colmap['upfile'][3];
            $res = $uplo->save_upload();
            if (PEAR::isError($res)) {
                $errs[] = $res->getMessage();
            } else {
                // get the name of the new file
예제 #6
0
파일: store.edit.php 프로젝트: sbeam/cshop
$fex->add_element($colmap);
/** POST rec'd, check valid, proc. upload and save if OK */
if (isset($_POST['f_op']) and ($ACTION == OP_ADD or $ACTION == OP_EDIT)) {
    $msg = '';
    $vals = array();
    $img_vals = array();
    if ($errs = $fex->validate($_POST)) {
        // handled below
    } else {
        $vals = $fex->get_submitted_vals($_POST);
        $upfiles = array('imageid' => array(), 'feature_imageid' => array());
        // tracks all new files we need to insert in media_prod table
        /** process each uploaded image **/
        foreach ($upfiles as $upfile => $img_vals) {
            // upfile =  name of field with uploaded file in it
            $uplo = new uploadable("f_{$upfile}");
            if (!$uplo->is_uploaded_file()) {
                /*
                if ($ACTION == OP_ADD and $upfile == 'imageid') {
                    $errs[] = 'You must upload image for this product!';
                }
                */
            } else {
                // we got one - use $uplo to check it and save it and create DB vals as needed
                $uplo->unique_filename = true;
                $uplo->preserve_original_name = true;
                $uplo->setErrorHandling(PEAR_ERROR_RETURN);
                // tell $uplo what kind of image we expect and where to put it:
                $uplo->params = $colmap[$upfile][3];
                $res = $uplo->save_upload();
                if (PEAR::isError($res)) {