}
     break;
 default:
     // product image
     for ($x = 0; $x < $this->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $x++) {
         // hidden filename that is retrieved from the ajax upload
         $i = $x;
         if ($i == 0) {
             $i = '';
         }
         $field = 'products_image' . $i;
         if ($key == $field) {
             // products image
             $size = getimagesize($file['tmp_name']);
             if ($size[0] > 5 and $size[1] > 5) {
                 $imgtype = mslib_befe::exif_imagetype($file['tmp_name']);
                 if ($imgtype) {
                     // valid image
                     $ext = image_type_to_extension($imgtype, false);
                     if ($ext) {
                         $i = 0;
                         $filename = mslib_fe::rewritenamein($this->post['products_name'][0]) . '.' . $ext;
                         $folder = mslib_befe::getImagePrefixFolder($filename);
                         $array = explode(".", $filename);
                         if (!is_dir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder)) {
                             \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder);
                         }
                         $folder .= '/';
                         $target = $this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename;
                         if (file_exists($target)) {
                             do {
 public function duplicateProduct($id_product, $target_categories_id)
 {
     if (!is_numeric($id_product)) {
         return false;
     }
     if (!is_numeric($target_categories_id)) {
         return false;
     }
     $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products', 'products_id=\'' . $id_product . '\'', '', '', '');
     $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) == 0) {
         return false;
     } else {
         //insert into tx_multishop_products
         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
         $product_arr_new = array();
         if (is_array($row) && count($row)) {
             foreach ($row as $key_p => $val_p) {
                 if ($key_p != 'products_id') {
                     if ($key_p == 'products_image' or $key_p == 'products_image1' or $key_p == 'products_image2' or $key_p == 'products_image3' or $key_p == 'products_image4') {
                         if (!empty($val_p)) {
                             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_description', 'products_id=\'' . $id_product . '\' and language_id=\'' . $this->sys_language_uid . '\'', '', '', '');
                             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
                             $row_desc = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
                             $file = mslib_befe::getImagePath($val_p, 'products', 'original');
                             //echo $file;
                             $imgtype = mslib_befe::exif_imagetype($file);
                             if ($imgtype) {
                                 // valid image
                                 $ext = image_type_to_extension($imgtype, false);
                                 if ($ext) {
                                     $i = 0;
                                     $filename = mslib_fe::rewritenamein($row_desc['products_name']) . '.' . $ext;
                                     //echo $filename;
                                     $folder = mslib_befe::getImagePrefixFolder($filename);
                                     $array = explode(".", $filename);
                                     if (!is_dir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder)) {
                                         \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder);
                                     }
                                     $folder .= '/';
                                     $target = $this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename;
                                     //echo $target;
                                     if (file_exists($target)) {
                                         do {
                                             $filename = mslib_fe::rewritenamein($row_desc['products_name']) . ($i > 0 ? '-' . $i : '') . '.' . $ext;
                                             $folder_name = mslib_befe::getImagePrefixFolder($filename);
                                             $array = explode(".", $filename);
                                             $folder = $folder_name;
                                             if (!is_dir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder)) {
                                                 \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder);
                                             }
                                             $folder .= '/';
                                             $target = $this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename;
                                             $i++;
                                             //echo $target . "<br/>";
                                         } while (file_exists($target));
                                     }
                                     if (copy($file, $target)) {
                                         $target_origineel = $target;
                                         $update_product_images = mslib_befe::resizeProductImage($target_origineel, $filename, $this->DOCUMENT_ROOT . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey));
                                     }
                                 }
                             }
                             $product_arr_new[$key_p] = $update_product_images;
                         } else {
                             $product_arr_new[$key_p] = $val_p;
                         }
                     } else {
                         $product_arr_new[$key_p] = $val_p;
                     }
                 }
             }
         }
         $product_arr_new['sort_order'] = time();
         $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products', $product_arr_new);
         $res = $GLOBALS['TYPO3_DB']->sql_query($query);
         $id_product_new = $GLOBALS['TYPO3_DB']->sql_insert_id();
         unset($product_arr_new);
         if ($id_product_new) {
             // insert tx_multishop_products_description
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_description', 'products_id=\'' . $id_product . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                 $product_arr_new = $row;
                 $product_arr_new['products_id'] = $id_product_new;
                 if (strpos($product_arr_new['products_name'], '(copy') === false) {
                     $product_arr_new['products_name'] .= ' (copy ' . $id_product_new . ')';
                 } else {
                     if (strpos($product_arr_new['products_name'], '(copy ' . $id_product . ')') !== false) {
                         $product_arr_new['products_name'] = str_replace('(copy ' . $id_product . ')', ' (copy ' . $id_product_new . ')', $product_arr_new['products_name']);
                     } else {
                         $product_arr_new['products_name'] = str_replace('(copy)', ' (copy ' . $id_product_new . ')', $product_arr_new['products_name']);
                     }
                 }
                 $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_description', $product_arr_new);
                 $res = $GLOBALS['TYPO3_DB']->sql_query($query);
             }
             // insert tx_multishop_products_attributes
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_attributes', 'products_id=\'' . $id_product . '\' and page_uid=\'' . $this->showCatalogFromPage . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) {
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                     $product_arr_new = $row;
                     $product_arr_new['products_id'] = $id_product_new;
                     $product_arr_new['page_uid'] = $this->showCatalogFromPage;
                     unset($product_arr_new['products_attributes_id']);
                     //primary key
                     $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_attributes', $product_arr_new);
                     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 }
             }
             // insert tx_multishop_specials
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_specials', 'products_id=\'' . $id_product . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) {
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                     $product_arr_new = $row;
                     $product_arr_new['products_id'] = $id_product_new;
                     unset($product_arr_new['specials_id']);
                     //primary key
                     $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_specials', $product_arr_new);
                     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 }
             }
             // insert tx_multishop_products_to_relative_products
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_products_to_relative_products', 'products_id=\'' . $id_product . '\' or relative_product_id = \'' . $id_product . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry) > 0) {
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                     $product_arr_new = $row;
                     if ($product_arr_new['products_id'] == $id_product) {
                         $product_arr_new['products_id'] = $id_product_new;
                     } else {
                         $product_arr_new['relative_product_id'] = $id_product_new;
                     }
                     unset($product_arr_new['products_to_relative_product_id']);
                     //primary key
                     $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_relative_products', $product_arr_new);
                     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
                 }
             }
             // insert into tx_multishop_products_to_categories
             $insertArray = array('products_id' => $id_product_new, 'categories_id' => $target_categories_id, 'sort_order' => time(), 'page_uid' => $this->showCatalogFromPage);
             //$query=$GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_products_to_categories', $insertArray);
             //$res=$GLOBALS['TYPO3_DB']->sql_query($query);
             // create categories tree linking
             $res = tx_mslib_catalog::linkCategoriesTreeToProduct($id_product_new, $target_categories_id, $insertArray);
             if ($res) {
                 if ($this->ms['MODULES']['FLAT_DATABASE']) {
                     mslib_befe::convertProductToFlat($id_product);
                 }
             } else {
                 return false;
             }
         }
     }
 }
 } else {
     foreach ($orders_products_attributes[$order['orders_products_id']] as $tmpkey => $options) {
         $options_attributes_tax_data = unserialize($options['attributes_tax_data']);
         if (is_numeric($options['products_options_id'])) {
             $str = $GLOBALS['TYPO3_DB']->SELECTquery('listtype', 'tx_multishop_products_options o', 'o.products_options_id=\'' . $options['products_options_id'] . '\' and language_id=\'' . $this->sys_language_uid . '\'', '', '', '');
             $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
             $rowCheck = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry);
         }
         $attributes_tax_data = unserialize($options['attributes_tax_data']);
         $tmpcontent .= '<tr class="' . $tr_type . '"><td>&nbsp;</td><td>&nbsp;</td>';
         if ($rowCheck['listtype'] == 'file') {
             if ($options['products_options_values']) {
                 $filePath = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/order_resources/' . rawurlencode($options['products_options_values']);
                 if (file_exists($filePath)) {
                     $displayImage = 0;
                     $imgtype = mslib_befe::exif_imagetype($filePath);
                     if ($imgtype) {
                         // valid image
                         $ext = image_type_to_extension($imgtype, false);
                         if ($ext) {
                             $displayImage = 1;
                         }
                     }
                     if ($displayImage) {
                         $size = getimagesize($filePath);
                         $width = '';
                         if ($size[0] > 350) {
                             $width = '150';
                         }
                         // display image with link
                         $htmlContent = '<br /><a href="' . $this->FULL_HTTP_URL . 'uploads/tx_multishop/order_resources/' . rawurlencode($options['products_options_values']) . '" class="msAdminDownloadIcon" target="_blank"><img src="' . $this->FULL_HTTP_URL . 'uploads/tx_multishop/order_resources/' . rawurlencode($options['products_options_values']) . '" width="' . $width . '" /></a>';
 function customAjaxPage(&$params, &$ref)
 {
     error_log("customAjaxPage hook");
     error_log("products path: " . $ref->ms['image_paths']['products']['original']);
     $ref->ms['image_paths']['variants']['original'] = 'uploads/tx_msvariants/images/original';
     error_log("variants path: " . $ref->ms['image_paths']['variants']['original']);
     if ($ref->ADMIN_USER) {
         if (isset($_SERVER["CONTENT_LENGTH"])) {
             //        switch ($ref->get['file_type']) {
             //          case 'variants_image':
             //          for ($x=0; $x<$ref->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $x++) {
             //              // hidden filename that is retrieved from the ajax upload
             //            $i=$x;
             //            if ($i==0) {
             //              $i='';
             //            }
             //            $field='products_image'.$i;
             //            if ($ref->get['file_type']==$field) {
             $temp_file = $ref->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . uniqid();
             if (isset($_FILES['qqfile'])) {
                 move_uploaded_file($_FILES['qqfile']['tmp_name'], $temp_file);
             } else {
                 $input = fopen("php://input", "r");
                 $debug_file = fopen("/Applications/XAMPP/xamppfiles/htdocs/typo3/typo3temp/debug.txt", "w");
                 fwrite($debug_file, sys_get_temp_dir());
                 fclose($debug_file);
                 $temp = tmpfile();
                 $realSize = stream_copy_to_stream($input, $temp);
                 fclose($input);
                 $target = fopen($temp_file, "w");
                 fseek($temp, 0, SEEK_SET);
                 stream_copy_to_stream($temp, $target);
                 fclose($target);
             }
             error_log("temp file created");
             $size = getimagesize($temp_file);
             if ($size[0] > 5 and $size[1] > 5) {
                 error_log("size ok");
                 $imgtype = mslib_befe::exif_imagetype($temp_file);
                 if ($imgtype) {
                     error_log("type ok");
                     // valid image
                     $ext = image_type_to_extension($imgtype, false);
                     if ($ext) {
                         error_log("ext ok");
                         $i = 0;
                         $filename = mslib_fe::rewritenamein($ref->get['products_name']) . '.' . $ext;
                         $folder = mslib_befe::getImagePrefixFolder($filename);
                         $array = explode(".", $filename);
                         if (!is_dir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder)) {
                             t3lib_div::mkdir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder);
                         }
                         error_log("mkdir ok");
                         $folder .= '/';
                         $target = $ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder . $filename;
                         if (file_exists($target)) {
                             error_log("file exists ok");
                             do {
                                 $filename = mslib_fe::rewritenamein($ref->get['products_name']) . ($i > 0 ? '-' . $i : '') . '.' . $ext;
                                 $folder_name = mslib_befe::getImagePrefixFolder($filename);
                                 $array = explode(".", $filename);
                                 $folder = $folder_name;
                                 if (!is_dir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder)) {
                                     t3lib_div::mkdir($ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder);
                                 }
                                 $folder .= '/';
                                 $target = $ref->DOCUMENT_ROOT . $ref->ms['image_paths']['variants']['original'] . '/' . $folder . $filename;
                                 $i++;
                             } while (file_exists($target));
                         }
                         error_log("before copy file ok");
                         if (copy($temp_file, $target)) {
                             $filename = mslib_befe::resizeProductImage($target, $filename, $ref->DOCUMENT_ROOT . t3lib_extMgm::siteRelPath($ref->extKey), 1);
                             $result = array();
                             $result['success'] = true;
                             $result['error'] = false;
                             $result['filename'] = $filename;
                             echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
                             exit;
                         }
                     }
                 }
             }
         }
         //          }
         //          break;
         //        }
         //      }
     }
     //    exit();
     //    break;
 }
Exemple #5
0
 $temp_file = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . uniqid();
 if (isset($_FILES['qqfile'])) {
     move_uploaded_file($_FILES['qqfile']['tmp_name'], $temp_file);
 } else {
     $input = fopen("php://input", "r");
     $temp = tmpfile();
     $realSize = stream_copy_to_stream($input, $temp);
     fclose($input);
     $target = fopen($temp_file, "w");
     fseek($temp, 0, SEEK_SET);
     stream_copy_to_stream($temp, $target);
     fclose($target);
 }
 $size = getimagesize($temp_file);
 if ($size[0] > 5 and $size[1] > 5) {
     $imgtype = mslib_befe::exif_imagetype($temp_file);
     if ($imgtype) {
         // valid image
         $ext = image_type_to_extension($imgtype, false);
         if ($ext) {
             $i = 0;
             $filename = mslib_fe::rewritenamein($tmp_filename) . '.' . $ext;
             $folder = mslib_befe::getImagePrefixFolder($filename);
             $array = explode(".", $filename);
             if (isset($this->get['old_image']) && !empty($this->get['old_image'])) {
                 $orFilter = array();
                 for ($i = 0; $i < $this->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $i++) {
                     $s = '';
                     if ($i > 0) {
                         $s = $i;
                     }
Exemple #6
0
 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['fetchManufacturersImagePreProc'])) {
     $params = array('rowchk' => &$rowchk, 'item' => &$item, 'column' => 'manufacturers_image');
     foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['fetchManufacturersImagePreProc'] as $funcRef) {
         \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
     }
 }
 // custom hook that can be controlled by third-party plugin eof
 if (!$rowchk['manufacturers_image']) {
     // download image
     $data = mslib_fe::file_get_contents($image);
     if ($data) {
         $plaatje1_name = $item['manufacturers_id'] . '-' . $colname . '-' . time();
         $tmpfile = PATH_site . 'uploads/tx_multishop/tmp/' . $plaatje1_name;
         file_put_contents($tmpfile, $data);
         $plaatje1 = $tmpfile;
         if (($extentie1 = mslib_befe::exif_imagetype($plaatje1)) && $plaatje1_name != '') {
             $extentie1 = image_type_to_extension($extentie1, false);
             $ext = $extentie1;
             $ix = 0;
             $filename = mslib_fe::rewritenamein($categories_name) . '.' . $ext;
             $folder = mslib_befe::getImagePrefixFolder($filename);
             if (!is_dir(PATH_site . $this->ms['image_paths']['manufacturers']['original'] . '/' . $folder)) {
                 \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir(PATH_site . $this->ms['image_paths']['manufacturers']['original'] . '/' . $folder);
             }
             $folder .= '/';
             $target = PATH_site . $this->ms['image_paths']['manufacturers']['original'] . '/' . $folder . $filename;
             if (file_exists($target)) {
                 do {
                     $filename = mslib_fe::rewritenamein($manufacturers_name) . ($ix > 0 ? '-' . $ix : '') . '.' . $ext;
                     $folder = mslib_befe::getImagePrefixFolder($filename);
                     if (!is_dir(PATH_site . $this->ms['image_paths']['manufacturers']['original'] . '/' . $folder)) {