public function saveImportedProductImages($products_id, $input, $item, $oldproduct = array(), $log_file = '') { if (!is_numeric($products_id)) { return false; } if (is_numeric($products_id)) { 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 = ''; } $colname = 'products_image' . $i; if (!$oldproduct[$colname]) { if ($item[$colname]) { $plaatje1 = $item[$colname]; $data = mslib_fe::file_get_contents($plaatje1); if ($data) { $plaatje1_name = $products_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($item['products_name']) . '.' . $ext; $folder = mslib_befe::getImagePrefixFolder($filename); if (!is_dir(PATH_site . $this->ms['image_paths']['products']['original'] . '/' . $folder)) { \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir(PATH_site . $this->ms['image_paths']['products']['original'] . '/' . $folder); } $folder .= '/'; $target = PATH_site . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename; if (file_exists($target)) { do { $filename = mslib_fe::rewritenamein($item['products_name']) . ($ix > 0 ? '-' . $ix : '') . '.' . $ext; $folder = mslib_befe::getImagePrefixFolder($filename); if (!is_dir(PATH_site . $this->ms['image_paths']['products']['original'] . '/' . $folder)) { \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir(PATH_site . $this->ms['image_paths']['products']['original'] . '/' . $folder); } $folder .= '/'; $target = PATH_site . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename; $ix++; } while (file_exists($target)); } // end $products_image = $path . '/' . $naam; // backup original $target = PATH_site . $this->ms['image_paths']['products']['original'] . '/' . $folder . $filename; copy($tmpfile, $target); // backup original eof $products_image_name = mslib_befe::resizeProductImage($target, $filename, PATH_site . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey), 1); $item['img'][$i] = $products_image_name; if ($log_file) { file_put_contents($log_file, 'Downloading product' . $i . ' image (' . $item[$colname] . ') succeeded and has been resized to ' . $item['img'][$i] . '.' . "\n", FILE_APPEND); } } else { $item['img'][$i] = ''; } } else { $item['img'][$i] = ''; if ($log_file) { file_put_contents($log_file, 'Downloading product' . $i . ' image (' . $item[$colname] . ') failed.' . "\n", FILE_APPEND); } } if ($tmpfile and file_exists($tmpfile)) { @unlink($tmpfile); } } else { $item['img'][$i] = ''; } } else { $item['img'][$i] = ''; } } if (count($item['img']) > 0) { $array = array(); for ($x = 0; $x < $this->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $x++) { $i = $x; if ($i == 0) { $i = ''; } if ($item['img'][$i]) { $colname = 'products_image' . $i; $array[$colname] = $item['img'][$i]; } } if (count($array) > 0) { if ($array['products_image']) { $array['contains_image'] = 1; } else { $array['contains_image'] = 0; } $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_products', 'products_id=' . $products_id, $array); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } } } }
} } if ($this->post['file_url']) { if (strstr($this->post['file_url'], "../")) { die; } $filename = time(); $file = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename; file_put_contents($file, mslib_fe::file_get_contents($this->post['file_url'])); } if ($this->post['filename']) { $file = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $this->post['filename']; } if ($this->post['database_name'] or $file) { if ($file) { $str = mslib_fe::file_get_contents($file); } if ($this->post['parser_template']) { // include a pre-defined xml to php array way require \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('multishop') . 'scripts/admin_pages/includes/admin_import_parser_templates/' . $this->post['parser_template'] . ".php"; // include a pre-defined xml to php array way eof } else { if ($this->post['database_name']) { if ($log_file) { file_put_contents($log_file, $this->FULL_HTTP_URL . ' - loading random products.(' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND); } if (is_numeric($this->get['limit'])) { $limit = $this->get['limit']; } else { $limit = 2000; }
$image = $item['manufacturers_image']; $strchk = "SELECT * from tx_multishop_manufacturers m where m.manufacturers_id='" . $item['manufacturers_id'] . "'"; $qrychk = $GLOBALS['TYPO3_DB']->sql_query($strchk); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qrychk)) { $rowchk = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qrychk); // custom hook that can be controlled by third-party plugin 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 .= '/';
\TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // custom page hook that can be controlled by third-party plugin eof // download action is valid. lets proceed if (!$row['file_location'] && $row['file_remote_location']) { // file is stored on remote location. lets download it and send it to the browser $body_data = mslib_fe::file_get_contents($row['file_remote_location']); if (!$row['file_label']) { $row['file_label'] = basename($row['file_remote_location']); } if (!$row['file_label']) { $row['file_label'] = $row['products_name']; } } elseif ($row['file_location'] and file_exists($row['file_location'])) { $body_data = mslib_fe::file_get_contents($row['file_location']); if (!$row['file_label']) { $row['file_label'] = $row['products_name']; } } if ($body_data) { if (!isset($this->get['tx_multishop_pi1']['from_interface'])) { $query = "update tx_multishop_orders_products set file_downloaded=(file_downloaded+1) where orders_products_id='" . $row['orders_products_id'] . "'"; $res = $GLOBALS['TYPO3_DB']->sql_query($query); $row['file_downloaded']++; if ($row['file_downloaded'] >= $row['file_number_of_downloads']) { // maximum allowed downloads exceeded. lets lock it. $updateArray = array('file_locked' => '1'); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_orders_products', 'orders_products_id=' . addslashes($row['orders_products_id']), $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); }
} if ($this->get) { foreach ($this->get as $get_idx => $get_val) { $this->post[$get_idx] = $get_val; } } $postErno = array(); switch ($this->post['tx_multishop_pi1']['action']) { case 'download_selected_orders_packingslips_in_one_pdf': if (is_array($this->post['selected_orders']) && count($this->post['selected_orders'])) { $attachments = array(); foreach ($this->post['selected_orders'] as $order_id) { $order = mslib_fe::getOrder($order_id); $pdfFileName = 'packingslip_' . $order_id . '.pdf'; $packingslip_path = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $pdfFileName; $packingslip_data = mslib_fe::file_get_contents($this->FULL_HTTP_URL . mslib_fe::typolink($this->shop_pid . ',2002', 'tx_multishop_pi1[page_section]=download_packingslip&tx_multishop_pi1[order_hash]=' . $order['hash'])); // write temporary to disk file_put_contents($packingslip_path, $packingslip_data); $attachments[] = $packingslip_path; } if (count($attachments)) { $combinedPdfFile = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . time() . '_' . uniqid() . '.pdf'; $prog = \TYPO3\CMS\Core\Utility\CommandUtility::exec('which gs'); //hook to let other plugins further manipulate the settings if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_befe.php']['overrideGhostScripPath'])) { $params = array('prog' => &$prog); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_befe.php']['overrideGhostScripPath'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } if ($prog && is_file($prog)) {
function mailOrder($orders_id, $copy_to_merchant = 1, $custom_email_address = '', $mail_template = '') { $order = mslib_fe::getOrder($orders_id); if ($order['orders_id']) { $order['mail_template'] = $mail_template; if (isset($order['language_id'])) { // Switch to language that is stored in the order mslib_befe::setSystemLanguage($order['language_id']); } if (!$custom_email_address) { $custom_email_address = $order['billing_email']; } $billing_address = ''; $delivery_address = ''; $full_customer_name = $order['billing_first_name']; if ($order['billing_middle_name']) { $full_customer_name .= ' ' . $order['billing_middle_name']; } if ($order['billing_last_name']) { $full_customer_name .= ' ' . $order['billing_last_name']; } $delivery_full_customer_name = $order['delivery_first_name']; if ($order['delivery_middle_name']) { $delivery_full_customer_name .= ' ' . $order['delivery_middle_name']; } if ($order['delivery_last_name']) { $delivery_full_customer_name .= ' ' . $order['delivery_last_name']; } $full_customer_name = preg_replace('/\\s+/', ' ', $full_customer_name); $delivery_full_customer_name = preg_replace('/\\s+/', ' ', $delivery_full_customer_name); if (!$order['delivery_address'] or !$order['delivery_city']) { $order['delivery_company'] = $order['billing_company']; $order['delivery_street_name'] = $order['billing_street_name']; $order['delivery_building'] = $order['billing_building']; $order['delivery_address'] = $order['billing_address']; $order['delivery_address_number'] = $order['billing_address_number']; $order['delivery_address_ext'] = $order['billing_address_ext']; $order['delivery_zip'] = $order['billing_zip']; $order['delivery_city'] = $order['billing_city']; $order['delivery_telephone'] = $order['billing_telephone']; $order['delivery_mobile'] = $order['billing_mobile']; } if ($order['delivery_company']) { $delivery_address = $order['delivery_company'] . "<br />"; } if ($delivery_full_customer_name) { $delivery_address .= $delivery_full_customer_name . "<br />"; } if ($order['delivery_building']) { $delivery_address .= $order['delivery_building'] . "<br />"; } if ($order['delivery_address']) { $delivery_address .= $order['delivery_address'] . "<br />"; } if ($order['delivery_zip'] and $order['delivery_city']) { $delivery_address .= $order['delivery_zip'] . " " . $order['delivery_city']; } if ($order['delivery_country'] && mslib_befe::strtolower($order['delivery_country']) != mslib_befe::strtolower($this->tta_shop_info['country'])) { // ONLY PRINT COUNTRY IF THE COUNTRY OF THE CUSTOMER IS DIFFERENT THAN FROM THE SHOP $delivery_address .= '<br />' . mslib_fe::getTranslatedCountryNameByEnglishName($this->lang, $order['delivery_country']); } // if ($order['delivery_telephone']) $delivery_address.=ucfirst($this->pi_getLL('telephone')).': '.$order['delivery_telephone']."<br />"; // if ($order['delivery_mobile']) $delivery_address.=ucfirst($this->pi_getLL('mobile')).': '.$order['delivery_mobile']."<br />"; if ($order['billing_company']) { $billing_address = $order['billing_company'] . "<br />"; } if ($full_customer_name) { $billing_address .= $full_customer_name . "<br />"; } if ($order['billing_building']) { $billing_address .= $order['billing_building'] . "<br />"; } if ($order['billing_address']) { $billing_address .= $order['billing_address'] . "<br />"; } if ($order['billing_zip'] and $order['billing_city']) { $billing_address .= $order['billing_zip'] . " " . $order['billing_city']; } if ($order['billing_country'] && mslib_befe::strtolower($order['billing_country']) != mslib_befe::strtolower($this->tta_shop_info['country'])) { // ONLY PRINT COUNTRY IF THE COUNTRY OF THE CUSTOMER IS DIFFERENT THAN FROM THE SHOP $billing_address .= '<br />' . mslib_fe::getTranslatedCountryNameByEnglishName($this->lang, $order['billing_country']); } $loadFromPids = array(); if ($this->conf['masterShop']) { $loadFromPids[] = $order['page_uid']; $loadFromPids[] = $this->shop_pid; if ($this->showCatalogFromPage and $this->showCatalogFromPage != $this->shop_pid) { $loadFromPids[] = $this->showCatalogFromPage; } } // psp email template $psp_mail_template = array(); if ($order['payment_method']) { $psp_data = mslib_fe::loadPaymentMethod($order['payment_method']); $psp_vars = unserialize($psp_data['vars']); if (isset($psp_vars['order_confirmation'])) { $psp_mail_template['order_confirmation'] = ''; if ($psp_vars['order_confirmation'] > 0) { $psp_mail_template['order_confirmation'] = mslib_fe::getCMSType($psp_vars['order_confirmation']); } } if (isset($psp_vars['order_paid'])) { $psp_mail_template['order_paid'] = ''; if ($psp_vars['order_paid'] > 0) { $psp_mail_template['order_paid'] = mslib_fe::getCMSType($psp_vars['order_paid']); } } } // loading the email template $page = array(); //hook to let other plugins further manipulate the replacers if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderPreCMSContent'])) { $params = array('page' => &$page, 'order' => &$order, 'mail_template' => $mail_template, 'psp_mail_template' => $psp_mail_template, 'loadFromPids' => $loadFromPids); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderPreCMSContent'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } if ($mail_template) { switch ($mail_template) { case 'email_order_paid_letter': if (isset($psp_mail_template['order_paid'])) { $page = array(); if (!empty($psp_mail_template['order_paid'])) { $page = mslib_fe::getCMScontent($psp_mail_template['order_paid'], $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); } } else { if ($order['payment_method']) { $page = mslib_fe::getCMScontent('email_order_paid_letter_' . $order['payment_method'], $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); } if (!count($page[0])) { $page = mslib_fe::getCMScontent('email_order_paid_letter', $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); } } break; default: $page = mslib_fe::getCMScontent($mail_template, $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); break; } } else { if ($order['is_proposal']) { // proposal template $mail_template = 'email_order_proposal'; $page = mslib_fe::getCMScontent($mail_template, $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); } else { // normal order template if (isset($psp_mail_template['order_confirmation'])) { $page = array(); if (!empty($psp_mail_template['order_confirmation'])) { $page = mslib_fe::getCMScontent($psp_mail_template['order_confirmation'], $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); } } else { if ($order['payment_method']) { $page = mslib_fe::getCMScontent('email_order_confirmation_' . $order['payment_method'], $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); } if (!count($page[0])) { $page = mslib_fe::getCMScontent('email_order_confirmation', $GLOBALS['TSFE']->sys_language_uid, $loadFromPids); } } } } //hook to let other plugins further manipulate the replacers if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderPostCMSContent'])) { $params = array('page' => &$page, 'order' => &$order, 'mail_template' => $mail_template, 'psp_mail_template' => $psp_mail_template, 'loadFromPids' => $loadFromPids); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderPostCMSContent'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } if ($page[0]['content']) { // loading the email confirmation letter eof // replacing the variables with dynamic values $array1 = array(); $array2 = array(); $array1[] = '###GENDER_SALUTATION###'; $array2[] = mslib_fe::genderSalutation($order['billing_gender']); // full billing name $array1[] = '###BILLING_FULL_NAME###'; $array2[] = $full_customer_name; $array1[] = '###FULL_NAME###'; $array2[] = $full_customer_name; $array1[] = '###BILLING_NAME###'; $array2[] = $order['billing_name']; $array1[] = '###BILLING_COMPANY###'; $array2[] = $order['billing_company']; $array1[] = '###BILLING_FIRST_NAME###'; $array2[] = $order['billing_first_name']; $array1[] = '###BILLING_LAST_NAME###'; $array2[] = preg_replace('/\\s+/', ' ', $order['billing_middle_name'] . ' ' . $order['billing_last_name']); $array1[] = '###BILLING_EMAIL###'; $array2[] = $order['billing_email']; $array1[] = '###BILLING_TELEPHONE###'; $array2[] = $order['billing_telephone']; $array1[] = '###BILLING_MOBILE###'; $array2[] = $order['billing_mobile']; // full delivery name $array1[] = '###DELIVERY_NAME###'; $array2[] = $order['delivery_name']; $array1[] = '###DELIVERY_FULL_NAME###'; $array2[] = $delivery_full_customer_name; $array1[] = '###DELIVERY_COMPANY###'; $array2[] = $order['delivery_company']; $array1[] = '###DELIVERY_FIRST_NAME###'; $array2[] = $order['delivery_first_name']; $array1[] = '###DELIVERY_LAST_NAME###'; $array2[] = preg_replace('/\\s+/', ' ', $order['delivery_middle_name'] . ' ' . $order['delivery_last_name']); $array1[] = '###DELIVERY_EMAIL###'; $array2[] = $order['delivery_email']; $array1[] = '###DELIVERY_TELEPHONE###'; $array2[] = $order['delivery_telephone']; $array1[] = '###DELIVERY_MOBILE###'; $array2[] = $order['delivery_mobile']; $array1[] = '###CUSTOMER_EMAIL###'; $array2[] = $order['billing_email']; if ($order['cruser_id'] && is_numeric($order['cruser_id'])) { $crUser = mslib_fe::getUser($order['cruser_id']); $array1[] = '###CREATED_BY_FIRST_NAME###'; $array2[] = preg_replace('/\\s+/', ' ', $crUser['first_name']); $array1[] = '###CREATED_BY_LAST_NAME###'; $array2[] = preg_replace('/\\s+/', ' ', $crUser['middle_name'] . ' ' . $crUser['last_name']); $array1[] = '###CREATED_BY_FULL_NAME###'; $array2[] = preg_replace('/\\s+/', ' ', $crUser['first_name'] . ' ' . $crUser['middle_name'] . ' ' . $crUser['last_name']); } else { $array1[] = '###CREATED_BY_FIRST_NAME###'; $array2[] = ''; $array1[] = '###CREATED_BY_LAST_NAME###'; $array2[] = ''; $array1[] = '###CREATED_BY_FULL_NAME###'; $array2[] = ''; } $time = $order['crdate']; $long_date = strftime($this->pi_getLL('full_date_format'), $time); $array1[] = '###ORDER_DATE_LONG###'; // ie woensdag 23 juni, 2010 $array2[] = $long_date; $array1[] = '###ORDER_DATE###'; // 21-12-2010 in localized format $array2[] = strftime("%x", $time); // backwards compatibility $array1[] = '###LONG_DATE###'; // ie woensdag 23 juni, 2010 $array2[] = $long_date; $time = time(); $long_date = strftime($this->pi_getLL('full_date_format'), $time); $array1[] = '###CURRENT_DATE_LONG###'; // ie woensdag 23 juni, 2010 $array2[] = $long_date; $array1[] = '###STORE_NAME###'; $array2[] = $this->ms['MODULES']['STORE_NAME']; $array1[] = '###TOTAL_AMOUNT###'; $array2[] = mslib_fe::amount2Cents($order['total_amount']); $array1[] = '###PROPOSAL_NUMBER###'; $array2[] = $order['orders_id']; $array1[] = '###ORDER_NUMBER###'; $array2[] = $order['orders_id']; $array1[] = '###ORDER_LINK###'; $array2[] = ''; $array1[] = '###ORDER_STATUS###'; $array2[] = $order['orders_status']; $array1[] = '###TRACK_AND_TRACE_CODE###'; $array2[] = $order['track_and_trace_code']; $array1[] = '###BILLING_ADDRESS###'; $array2[] = $billing_address; $array1[] = '###DELIVERY_ADDRESS###'; $array2[] = $delivery_address; $array1[] = '###BILLING_STREET_NAME###'; $array2[] = $order['billing_street_name']; $array1[] = '###BILLING_ADDRESS_NUMBER###'; $array2[] = $order['billing_address_number']; $array1[] = '###BILLING_ADDRESS_EXT###'; $array2[] = $order['billing_address_ext']; $array1[] = '###BILLING_ZIP###'; $array2[] = $order['billing_zip']; $array1[] = '###BILLING_CITY###'; $array2[] = $order['billing_city']; $array1[] = '###BILLING_COUNTRY###'; $array2[] = mslib_fe::getTranslatedCountryNameByEnglishName($this->lang, $order['billing_country']); $array1[] = '###DELIVERY_STREET_NAME###'; $array2[] = $order['delivery_street_name']; $array1[] = '###DELIVERY_ADDRESS_NUMBER###'; $array2[] = $order['delivery_address_number']; $array1[] = '###DELIVERY_ADDRESS_EXT###'; $array2[] = $order['delivery_address_ext']; $array1[] = '###DELIVERY_ZIP###'; $array2[] = $order['delivery_zip']; $array1[] = '###DELIVERY_CITY###'; $array2[] = $order['delivery_city']; $array1[] = '###DELIVERY_COUNTRY###'; $array2[] = mslib_fe::getTranslatedCountryNameByEnglishName($this->lang, $order['delivery_country']); $array1[] = '###CUSTOMER_ID###'; $array2[] = $order['customer_id']; $ORDER_DETAILS = self::printOrderDetailsTable($order, 'email'); if ($this->ms['MODULES']['CREATE_INVOICE_DIRECTLY_AFTER_CREATING_ORDER']) { // FORCE CREATE INVOICE IF NOT ALREADY EXISTING $invoice = mslib_fe::getOrderInvoice($order['orders_id'], 1); } else { $invoice = mslib_fe::getOrderInvoice($order['orders_id'], 0); } $invoice_id = ''; $invoice_link = ''; if (is_array($invoice)) { $invoice_id = $invoice['invoice_id']; $invoice_link = '<a href="' . $this->FULL_HTTP_URL . mslib_fe::typolink($this->shop_pid . ',2002', '&tx_multishop_pi1[page_section]=download_invoice&tx_multishop_pi1[hash]=' . $invoice['hash']) . '">' . $invoice['invoice_id'] . '</a>'; } $array1[] = '###INVOICE_NUMBER###'; $array2[] = $invoice_id; $array1[] = '###INVOICE_LINK###'; $array2[] = $invoice_link; $array1[] = '###ORDER_DETAILS###'; $array2[] = $ORDER_DETAILS; $array1[] = '###SHIPPING_METHOD###'; $array2[] = $order['shipping_method_label']; $array1[] = '###PAYMENT_METHOD###'; $array2[] = $order['payment_method_label']; $array1[] = '###EXPECTED_DELIVERY_DATE###'; if ($order['expected_delivery_date'] > 0) { $array2[] = strftime("%x", $order['expected_delivery_date']); } else { $array2[] = ''; } $array1[] = '###EXPECTED_DELIVERY_DATE_LONG###'; if ($order['expected_delivery_date'] > 0) { $array2[] = strftime($this->pi_getLL('full_date_format'), $order['expected_delivery_date']); } else { $array2[] = ''; } $array1[] = '###CUSTOMER_COMMENTS###'; $array2[] = $order['customer_comments']; if ($order['customer_id'] > 0) { $user = mslib_fe::getUser($order['customer_id']); $array1[] = '###USERNAME###'; $array2[] = $user['username']; if (isset($this->post['password']) && !empty($this->post['password']) && $order['customer_id'] > 0) { $array1[] = '###PASSWORD###'; $array2[] = $this->post['password']; } } //hook to let other plugins further manipulate the replacers if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderReplacersPostProc'])) { $params = array('array1' => &$array1, 'array2' => &$array2, 'order' => &$order, 'mail_template' => $mail_template, 'loadFromPids' => $loadFromPids); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderReplacersPostProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } // Copy $pageCopyToMerchant = $page; if ($page[0]['content']) { $page[0]['content'] = str_replace($array1, $array2, $page[0]['content']); } if ($page[0]['name']) { $page[0]['name'] = str_replace($array1, $array2, $page[0]['name']); } // replacing the variables with dynamic values eof $user = array(); $user['name'] = $full_customer_name; $user['email'] = $custom_email_address; //hook $send_mail = 1; $mail_attachment = array(); $add_invoice_attachment_on_templates = array(); $add_invoice_attachment_on_templates[] = 'email_order_paid_letter'; if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrder'])) { $params = array('this' => &$this, 'page' => &$page, 'content' => &$content, 'send_mail' => &$send_mail, 'user' => $user, 'order' => $order, 'order_details' => $ORDER_DETAILS, 'copy_to_merchant' => $copy_to_merchant, 'mail_attachment' => &$mail_attachment, 'loadFromPids' => $loadFromPids, 'add_invoice_attachment_on_templates' => &$add_invoice_attachment_on_templates); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrder'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this); } } if ($send_mail) { if ($user['email']) { if (in_array($mail_template, $add_invoice_attachment_on_templates) && $this->ms['MODULES']['ATTACH_INVOICE_PDF_IN_PAID_LETTER_EMAIL'] > 0) { $filterInvoice = array(); $filterInvoice[] = 'orders_id=' . $order['orders_id']; $invoices = mslib_befe::getRecords('', 'tx_multishop_invoices', '', $filterInvoice, '', 'id desc'); $invoice = $invoices[0]; $pdfFileName = $invoice['invoice_id'] . '_' . $invoice['orders_id'] . '.pdf'; $pdfFilePath = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $pdfFileName; // generate the invoice PDF // Get Language code (ie nl, en, de) $language_code = mslib_befe::getLanguageIso2ByLanguageUid($order['language_id']); $language_code = strtolower($language_code); // Download invoice in the language of the order $invoice_data = mslib_fe::file_get_contents($this->FULL_HTTP_URL . mslib_fe::typolink($this->shop_pid . ',2002', 'tx_multishop_pi1[page_section]=download_invoice&tx_multishop_pi1[hash]=' . $invoice['hash'] . '&tx_multishop_pi1[forceRecreate]=1&language=' . $language_code)); file_put_contents($pdfFilePath, $invoice_data); $mail_attachment[] = $pdfFilePath; } mslib_fe::mailUser($user, $page[0]['name'], $page[0]['content'], $this->ms['MODULES']['STORE_EMAIL'], $this->ms['MODULES']['STORE_NAME'], $mail_attachment); // moved to cleaning up section //if (strpos($mail_template, 'email_order_paid_letter')!==false && $this->ms['MODULES']['ATTACH_INVOICE_PDF_IN_PAID_LETTER_EMAIL']>0 && file_exists($pdfFilePath)) { // unlink($pdfFilePath); //} } if ($copy_to_merchant) { $mailSubject = ''; if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderToMerchant'])) { $conf = array('this' => &$this, 'page' => &$page, 'content' => &$content, 'send_mail' => &$send_mail, 'user' => $user, 'order' => $order, 'order_details' => $ORDER_DETAILS, 'mail_attachment' => &$mail_attachment, 'mail_template' => $mail_template, 'psp_mail_template' => $psp_mail_template, 'loadFromPids' => $loadFromPids, 'mailSubject' => &$mailSubject, 'pageCopyToMerchant' => &$pageCopyToMerchant, 'array1' => &$array1, 'array2' => &$array2); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_fe.php']['mailOrderToMerchant'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $conf, $this); } } if ($pageCopyToMerchant[0]['content']) { $pageCopyToMerchant[0]['content'] = str_replace($array1, $array2, $pageCopyToMerchant[0]['content']); } if ($pageCopyToMerchant[0]['name']) { $pageCopyToMerchant[0]['name'] = str_replace($array1, $array2, $pageCopyToMerchant[0]['name']); } if ($mailSubject == '') { $mailSubject = $this->pi_getLL('copy_for_merchant') . ': ' . $pageCopyToMerchant[0]['name']; } // now mail a copy to the merchant $merchant = array(); $merchant['name'] = $this->ms['MODULES']['STORE_NAME']; $merchant['email'] = $this->ms['MODULES']['STORE_EMAIL']; mslib_fe::mailUser($merchant, $mailSubject, $pageCopyToMerchant[0]['content'], $this->ms['MODULES']['STORE_EMAIL'], $this->ms['MODULES']['STORE_NAME'], $mail_attachment); if ($this->ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO']) { $email = array(); if (!strstr($this->ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO'], ",")) { $email[] = $this->ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO']; } else { $email = explode(',', $this->ms['MODULES']['SEND_ORDER_CONFIRMATION_LETTER_ALSO_TO']); } if (count($email)) { foreach ($email as $item) { $merchant = array(); $merchant['name'] = $this->ms['MODULES']['STORE_NAME']; $merchant['email'] = $item; mslib_fe::mailUser($merchant, $mailSubject, $pageCopyToMerchant[0]['content'], $this->ms['MODULES']['STORE_EMAIL'], $this->ms['MODULES']['STORE_NAME'], $mail_attachment); } } } } // cleaning up the temporary attachment files if (is_array($mail_attachment) && count($mail_attachment)) { foreach ($mail_attachment as $filepath) { if (strpos($filepath, 'tx_multishop/tmp') !== false) { if (file_exists($filepath)) { @unlink($filepath); } } } } } } if (isset($order['language_id'])) { // Switch back to default language mslib_befe::resetSystemLanguage(); } return 1; } }
function renderInterface($params, &$that) { mslib_fe::init($that); if ($that->post['job_id']) { $that->get['job_id'] = $that->post['job_id']; } if ($that->get['delete'] and is_numeric($that->get['job_id'])) { // delete job $query = $GLOBALS['TYPO3_DB']->DELETEquery('tx_multishop_import_jobs', 'id=' . $that->get['job_id'] . ' and type=\'' . addslashes($params['importKey']) . '\''); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } if (is_numeric($that->get['job_id']) and is_numeric($that->get['status'])) { // update the status of a job $updateArray = array(); $updateArray['status'] = $that->get['status']; $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=\'' . $that->get['job_id'] . '\' and type=\'' . addslashes($params['importKey']) . '\'', $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); // update the status of a job eof } if (isset($that->get['download']) && $that->get['download'] == 'task' && is_numeric($that->get['job_id'])) { $sql = $GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_multishop_import_jobs ', 'id= \'' . $that->get['job_id'] . '\'', '', '', ''); $qry = $GLOBALS['TYPO3_DB']->sql_query($sql); if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry)) { $data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $jobArray = $row; $serial_value = array(); foreach ($data as $key_idx => $key_val) { if ($key_idx != 'id' && $key_idx != 'page_uid') { $serial_value[$key_idx] = $key_val; } } $serial_data = ''; if (count($serial_value) > 0) { $serial_data = serialize($serial_value); } $filename = 'multishop_' . $params['importKey'] . '_import_task_' . date('YmdHis') . '_' . $that->get['job_id'] . '.txt'; $filepath = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/' . $filename; file_put_contents($filepath, $serial_data); header("Content-disposition: attachment; filename={$filename}"); //Tell the filename to the browser header('Content-type: application/octet-stream'); //Stream as a binary file! So it would force browser to download readfile($filepath); //Read and stream the file @unlink($filepath); exit; } } if (isset($that->get['upload']) && $that->get['upload'] == 'task' && $_FILES) { if (!$_FILES['task_file']['error']) { $filename = $_FILES['task_file']['name']; $target = $that->DOCUMENT_ROOT . '/uploads/tx_multishop' . $filename; if (move_uploaded_file($_FILES['task_file']['tmp_name'], $target)) { $task_content = file_get_contents($target); $unserial_task_data = unserialize($task_content); $insertArray = array(); $insertArray['page_uid'] = $that->showCatalogFromPage; foreach ($unserial_task_data as $col_name => $col_val) { if ($col_name == 'code') { $insertArray[$col_name] = md5(uniqid()); } else { if ($col_name == 'name' && isset($that->post['new_cron_name']) && !empty($that->post['new_cron_name'])) { $insertArray[$col_name] = $that->post['new_cron_name']; } else { if ($col_name == 'prefix_source_name' && isset($that->post['new_prefix_source_name']) && !empty($that->post['new_prefix_source_name'])) { $insertArray[$col_name] = $that->post['new_prefix_source_name']; } else { $insertArray[$col_name] = $col_val; } } } } $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_import_jobs', $insertArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); @unlink($target); } } header('Location: ' . $that->FULL_HTTP_URL . $params['postForm']['actionUrl'] . '#tasks'); } $GLOBALS['TSFE']->additionalHeaderData['tx_multishop_pi1_block_ui'] = mslib_fe::jQueryBlockUI(); if (is_numeric($that->post['job_id']) && $that->post['action'] == 'import-preview') { if ($that->post['job_id']) { $that->get['job_id'] = $that->post['job_id']; } $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->post['job_id'] . "' and type='" . addslashes($params['importKey']) . "'"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $jobArray = $row; $updateArray = array(); $cron_data = array(); $cron_data[0] = array(); $that->post['cron_period'] = ''; $cron_data[1] = $that->post; $updateArray['data'] = serialize($cron_data); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $that->post['job_id'], $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } if ($that->post['action'] == 'import-preview' or is_numeric($that->get['job_id']) and $_REQUEST['action'] == 'edit_job') { // preview if (is_numeric($that->get['job_id'])) { $that->ms['mode'] = 'edit'; // load the job $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->get['job_id'] . "' and type='" . addslashes($params['importKey']) . "'"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $jobArray = $row; $data = unserialize($row['data']); // copy the previous post data to the current post so it can run the job // again $that->post = $data[1]; $that->post['cid'] = $row['categories_id']; // enable file logging if ($that->get['relaxed_import']) { $that->post['relaxed_import'] = $that->get['relaxed_import']; } // update the last run time $updateArray = array(); $updateArray['last_run'] = time(); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $row['id'], $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); // update the last run time eof } if ($that->post['database_name']) { $file_location = $that->post['database_name']; } elseif ($that->post['file_url']) { if (strstr($that->post['file_url'], "../")) { die; } $filename = time(); $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename; $file_content = mslib_fe::file_get_contents($that->post['file_url']); if (!$file_content or !file_put_contents($file_location, $file_content)) { die('cannot save the file or the file is empty'); } } elseif ($that->ms['mode'] == 'edit') { $filename = $that->post['filename']; $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename; } if ($_FILES['file']['tmp_name']) { $file = $_FILES['file']['tmp_name']; $filename = time() . '.import'; $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename; $that->post['filename'] = $filename; move_uploaded_file($file, $file_location); if (preg_match("/\\.gz\$/", $_FILES['file']['name'])) { // lets uncompress realtime $str = mslib_fe::file_get_contents($file_location, 1); file_put_contents($file_location, $str); } } if ($this->ms['mode'] == 'edit' and is_array($data) and count($data) and $filename) { if ($filename) { $data[1]['filename'] = $filename; $this->post['filename'] = $filename; } $string = serialize($data); $updateArray = array(); $updateArray['data'] = $string; $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $_REQUEST['job_id'], $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } if ($file_location and $this->ms['mode'] == 'edit') { // if file not exists then show form to upload new file if (!file_exists($file_location)) { $content .= '<h2>Feed no longer available</h2>' . $file_location . ' is not existing.'; } } if (file_exists($file_location) or $that->post['database_name']) { if (!$that->post['database_name']) { $str = mslib_fe::file_get_contents($file_location); } if ($that->post['parser_template']) { $processed = 0; $rows = array(); } else { if ($str && mslib_befe::isSerializedString($str)) { $tmpData = unserialize($str); $counter = 0; foreach ($tmpData as $data) { $colCounter = 0; if ($counter == 0) { $row = array(); foreach ($data as $key => $val) { $row[] = $key; } $table_cols = $row; } $row = array(); foreach ($data as $key => $val) { $row[] = $val; } $rows[] = $row; $counter++; if ($counter == 5) { break; } } } elseif ($that->post['database_name']) { if ($that->ms['mode'] == 'edit') { $limit = 10; } else { $limit = '10'; } if (strstr(mslib_befe::strtolower($that->post['database_name']), 'select ')) { // its not a table name, its a full query $that->databaseMode = 'query'; $str = $that->post['database_name'] . ' LIMIT ' . $limit; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); if ($that->conf['debugEnabled'] == '1') { $logString = 'Load records for importer query: ' . $str; \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($logString, 'multishop', -1); } $datarows = array(); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) { $datarows[] = $row; } } else { $datarows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $that->post['database_name'], '', '', '', $limit); } $i = 0; $table_cols = array(); foreach ($datarows as $datarow) { $s = 0; foreach ($datarow as $colname => $datacol) { $table_cols[$s] = $colname; $rows[$i][$s] = $datacol; $s++; } $i++; if ($i == 5) { break; } } } elseif ($that->post['format'] == 'excel') { if (!$that->ms['mode'] == 'edit') { $filename = 'tmp-file-' . $GLOBALS['TSFE']->fe_user->user['uid'] . '-cat-' . $that->post['cid'] . '-' . time() . '.txt'; if (!($handle = fopen($that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename, 'w'))) { exit; } if (fwrite($handle, $str) === false) { exit; } fclose($handle); } // excel $paths = array(); $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Resources/Private/Contributed/PHPExcel/IOFactory.php'; $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Classes/PHPExcel/IOFactory.php'; foreach ($paths as $path) { if (file_exists($path)) { require_once $path; break; } } $phpexcel = PHPExcel_IOFactory::load($file_location); foreach ($phpexcel->getWorksheetIterator() as $worksheet) { $counter = 0; foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); foreach ($cellIterator as $cell) { $clean_products_data = ltrim(rtrim($cell->getCalculatedValue(), " ,"), " ,"); $clean_products_data = trim($clean_products_data); if ($row->getRowIndex() > 1) { $rows[$counter - 1][] = $clean_products_data; } else { $table_cols[] = mslib_befe::strtolower($clean_products_data); } } $counter++; if ($counter == 5) { break; } } } // excel eol } elseif ($that->post['format'] == 'xml') { // try the generic way if (!$that->ms['mode'] == 'edit') { $filename = 'tmp-file-' . $GLOBALS['TSFE']->fe_user->user['uid'] . '-cat-' . $that->post['cid'] . '-' . time() . '.txt'; if (!($handle = fopen($that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename, 'w'))) { exit; } if (fwrite($handle, $str) === false) { exit; } fclose($handle); } // try the generic way $objXML = new xml2Array(); $arrOutput = $objXML->parse($str); $i = 0; $s = 0; $rows = array(); foreach ($arrOutput[0]['children'] as $item) { foreach ($item['children'] as $internalitem) { $rows[$i][$s] = $internalitem['tagData']; $s++; } // foreach ($item['attrs'] as $key => $value) // { // $rows[$i][$s] = $value; // $s++; // } $i++; $s = 0; if ($i == 5) { break; } } } else { if ($that->post['os'] == 'linux') { $splitter = "\n"; } else { $splitter = "\r\n"; } // csv if ($that->post['delimiter'] == "tab") { $delimiter = "\t"; } elseif ($that->post['delimiter'] == "dash") { $delimiter = "|"; } elseif ($that->post['delimiter'] == "dotcomma") { $delimiter = ";"; } elseif ($that->post['delimiter'] == "comma") { $delimiter = ","; } else { $delimiter = "\t"; } if ($that->post['backquotes']) { $backquotes = '"'; } else { $backquotes = '"'; } if ($that->post['format'] == 'txt') { $row = 1; $rows = array(); if (($handle = fopen($file_location, "r")) !== false) { $counter = 0; while (($data = fgetcsv($handle, '', $delimiter, $backquotes)) !== false) { //print_r($data); if ($that->post['escape_first_line']) { if ($counter == 0) { $table_cols = $data; } else { $rows[] = $data; } } else { $rows[] = $data; } $counter++; if ($counter == 5) { break; } } fclose($handle); } } // csv } // try the generic way eol } $tmpcontent = ''; $tmpcontent .= '<div class="panel-body"> <form id="product_import_form" class="form-horizontal" name="form1" method="post" action="' . $params['postForm']['actionUrl'] . '"> <input name="consolidate" type="hidden" value="' . $that->post['consolidate'] . '" /> <input name="os" type="hidden" value="' . $that->post['os'] . '" /> <input name="escape_first_line" type="hidden" value="' . $that->post['escape_first_line'] . '" /> <input name="parser_template" type="hidden" value="' . $that->post['parser_template'] . '" /> <input name="format" type="hidden" value="' . $that->post['format'] . '" /> <input name="action" type="hidden" value="import" /> <input name="delimiter" type="hidden" value="' . $that->post['delimiter'] . '" /> <input name="backquotes" type="hidden" value="' . $that->post['backquotes'] . '" /> <input name="filename" type="hidden" value="' . $filename . '" /> <input name="file_url" type="hidden" value="' . $that->post['file_url'] . '" /> '; if ($that->ms['mode'] == 'edit' or $that->post['preProcExistingTask']) { // if the existing import task is rerunned indicate it so we dont save the task double $tmpcontent .= '<input name="preProcExistingTask" type="hidden" value="1" />'; } if (!$rows) { $tmpcontent .= '<div class="alert alert-danger"><h3>No data available.</h3></div>'; } else { $tmpcontent .= '<table id="product_import_table" class="table table-striped table-bordered">'; $header = '<thead><tr><th>' . $that->pi_getLL('target_column') . '</th><th>' . $that->pi_getLL('source_column') . '</th>'; for ($x = 1; $x < 6; $x++) { $header .= '<th>' . $that->pi_getLL('row') . ' ' . $x . '</th>'; } $header .= '</tr></thead>'; $tmpcontent .= $header; $cols = count($rows[0]); $preview_listing = array(); for ($i = 0; $i < $cols; $i++) { if ($switch == 'odd') { $switch = 'even'; } else { $switch = 'odd'; } $tmpcontent .= ' <tr class="' . $switch . '"> <td class="cellAux"> <div class="form-inline"> <select name="select[' . $i . ']" id="select[' . $i . ']" class="select_columns_fields"> <option value="">' . $that->pi_getLL('skip') . '</option> '; foreach ($params['importColumns'] as $key => $value) { $tmpcontent .= '<option value="' . $key . '" ' . ($that->post['select'][$i] != '' && $that->post['select'][$i] == $key ? 'selected' : '') . '>' . htmlspecialchars($value) . '</option>'; } $tmpcontent .= ' </select> <input name="advanced_settings" class="btn btn-primary importer_advanced_settings" type="button" value="' . $that->pi_getLL('admin_advanced_settings') . '" /> </div> <div class="advanced_settings_container" style="display:none;"> <div class="form-group no-mb"> <div class="col-md-12"> <label class="control-label">aux</label> <input name="input[' . $i . ']" class="form-control" type="text" value="' . htmlspecialchars($this->post['input'][$i]) . '"> </div> </div> </fieldset> </td> <td class="column_name"><strong>' . htmlspecialchars($table_cols[$i]) . '</strong></td> '; // now 5 records $teller = 0; foreach ($rows as $row) { foreach ($row as $key => $col) { if (!mb_detect_encoding($col, 'UTF-8', true)) { $row[$key] = mslib_befe::convToUtf8($col); } } $teller++; $tmpitem = $row; $cols = count($tmpitem); if ($that->post['backquotes']) { $tmpitem[$i] = trim($tmpitem[$i], "\""); } if (strlen($tmpitem[$i]) > 100) { $tmpitem[$i] = substr($tmpitem[$i], 0, 100) . '...'; } $tmpcontent .= '<td class="cellBreak product_' . $teller . '">' . htmlspecialchars($tmpitem[$i]) . '</td>'; if ($teller == 5 or $teller == count($rows)) { break; } } if ($teller < 5) { for ($x = $teller; $x < 5; $x++) { $tmpcontent .= '<td class="cellBreak product_' . $x . '"> </td>'; } } // now 5 products eof $tmpcontent .= ' </tr>'; /* * prefix '.$i.': <input name="input['.$i.']" type="text" * value="'.htmlspecialchars($that->post['input'][$i]).'" /> */ } $importer_add_aux_input = ' <div class="form-field ms_dynamic_add_property"> <label>type</label> <select name="type"> <option value="append">append content with value</option> <option value="prepend">prepend content with value</option> <option value="find_and_replace">find and replace</option> <option value="custom_code">custom php code</option> </select> <label>aux</label> <input name="aux_input[]" type="text" value="' . htmlspecialchars($that->post['aux_input']) . '" /> <input name="delete" class="delete_property" type="button" value="delete" /><input name="disable" type="button" value="enable" /> </div> '; $importer_add_aux_input = str_replace("\r\n", '', $importer_add_aux_input); $importer_add_aux_input = str_replace("\n", '', $importer_add_aux_input); $tmpcontent .= $header . '</table>'; $tmpcontent .= ' <script type="text/javascript"> jQuery(document).ready(function($) { var add_property_html=\'' . addslashes($importer_add_aux_input) . '\'; $(document).on("click", ".delete_property", function() { $(this).parent().hide("fast"); }); $(".importer_add_property").click(function(event) { $(this).prev().append(add_property_html); }); $(".importer_advanced_settings").click(function(event) { $(this).parent().next().toggle(); }); $(\'.select_columns_fields\').select2({ dropdownCssClass: "bigdropWider", // apply css that makes the dropdown taller width:\'250px\' }); }); </script> '; } //$tmpcontent.=self::renderImportJobProperties($params,$that); $tmpcontent .= ' <div class="panel panel-default"> <div class="panel-heading"><h3>' . $that->pi_getLL('save_import_task') . '</h3></div> <div class="panel-body"> <div class="form-group"> <label for="cron_name" class="control-label col-md-2">' . $that->pi_getLL('name') . '</label> <div class="col-md-10"> <input name="cron_name" type="text" class="form-control" value="' . htmlspecialchars($that->post['cron_name']) . '" /> </div> </div> '; if ($that->get['action'] == 'edit_job') { $tmpcontent .= ' <div class="form-group"> <label for="duplicate" class="control-label col-md-2">' . $that->pi_getLL('duplicate') . '</label> <div class="col-md-10"> <div class="checkbox checkbox-success checkbox-inline"> <input name="duplicate" id="duplicate" type="checkbox" value="1" /><label for="duplicate"></label> <input name="skip_import" type="hidden" value="1" /> <input name="job_id" type="hidden" value="' . $that->get['job_id'] . '" /> <input name="file_url" type="hidden" value="' . $that->post['file_url'] . '" /> </div> </div> </div> '; } $tmpcontent .= ' <div class="form-group"> <label for="cron_period" class="control-label col-md-2">' . $that->pi_getLL('schedule') . '</label> <div class="col-md-10"> <select name="cron_period" id="cron_period" class="form-control"> <option value="" ' . (!$that->post['cron_period'] ? 'selected' : '') . '>' . $that->pi_getLL('manual') . '</option> <option value="' . 3600 * 24 . '" ' . ($that->post['cron_period'] == 3600 * 24 ? 'selected' : '') . '>' . $that->pi_getLL('daily') . '</option> <option value="' . 3600 * 24 * 7 . '" ' . ($that->post['cron_period'] == 3600 * 24 * 7 ? 'selected' : '') . '>' . $that->pi_getLL('weekly') . '</option> <option value="' . 3600 * 24 * 30 . '" ' . ($that->post['cron_period'] == 3600 * 24 * 30 ? 'selected' : '') . '>' . $that->pi_getLL('monthly') . '</option> </select> </div> </div> <div class="form-group"> <label for="prefix_source_name" class="control-label col-md-2">' . $that->pi_getLL('source_name') . '</label> <div class="col-md-10"> <input name="prefix_source_name" type="text" class="form-control" value="' . htmlspecialchars($that->post['prefix_source_name']) . '" /> </div> </div> <input name="database_name" type="hidden" value="' . $that->post['database_name'] . '" /> <input name="cron_data" type="hidden" value="' . htmlspecialchars(serialize($that->post)) . '" /> <div class="form-group"> <div class="col-md-10 col-md-offset-2"> <button type="submit" class="btn btn-success submit_block" id="cl_submit" name="AdSubmit" value=""><i class="fa fa-save"></i> ' . ($that->get['action'] == 'edit_job' ? $that->pi_getLL('save') : $that->pi_getLL('import')) . '</button> </div> </div> </div> </div> </form> '; $content = '' . mslib_fe::shadowBox($tmpcontent) . ''; // $content='<div // class="fullwidth_div">'.mslib_fe::shadowBox($tmpcontent).'</div>'; } // preview eof } elseif (is_numeric($that->get['job_id']) and $that->get['action'] == 'run_job' or $that->post['action'] == 'import' and ($that->post['filename'] and file_exists($that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $that->post['filename']) or $that->post['database_name'])) { if (!$that->post['preProcExistingTask'] and $that->post['cron_name'] and !$that->post['skip_import'] or $that->post['skip_import'] and $that->post['duplicate']) { // we have to save the import job $updateArray = array(); $updateArray['name'] = $that->post['cron_name']; $updateArray['status'] = 1; $updateArray['last_run'] = time(); $updateArray['code'] = md5(uniqid()); $updateArray['period'] = $that->post['cron_period']; $updateArray['prefix_source_name'] = $that->post['prefix_source_name']; $cron_data = array(); $cron_data[0] = unserialize($that->post['cron_period']); $that->post['cron_period'] = ''; $cron_data[1] = $that->post; $updateArray['data'] = serialize($cron_data); $updateArray['page_uid'] = $that->shop_pid; $updateArray['categories_id'] = $that->post['cid']; $updateArray['type'] = $params['importKey']; $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_import_jobs', $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); // we have to save the import job eof $that->ms['show_default_form'] = 1; } elseif ($that->post['skip_import']) { // we have to update the import job $updateArray = array(); $updateArray['name'] = $that->post['cron_name']; $updateArray['status'] = 1; $updateArray['last_run'] = time(); $updateArray['period'] = $that->post['cron_period']; $updateArray['prefix_source_name'] = $that->post['prefix_source_name']; $cron_data = array(); $cron_data[0] = unserialize($that->post['cron_period']); $that->post['cron_period'] = ''; $cron_data[1] = $that->post; $updateArray['data'] = serialize($cron_data); $updateArray['page_uid'] = $that->shop_pid; $updateArray['categories_id'] = $that->post['cid']; $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $that->post['job_id'] . ' and type=\'' . addslashes($params['importKey']) . '\'', $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); // we have to update the import job eof $that->ms['show_default_form'] = 1; } if (!$that->post['skip_import']) { if (!$that->get['job_id'] && $that->post['cron_data']) { $data = unserialize($that->post['cron_data']); if (is_numeric($data['job_id'])) { // NEW STUFF FOR 123 IMPORT APPROACH WITH PREDEFINED VALUES TEST $that->get['job_id'] = $data['job_id']; // load the job $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->get['job_id'] . "'" . ' and type=\'' . addslashes($params['importKey']) . '\''; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $jobArray = $row; $cron_data = array(); $cron_data[0] = array(); $that->post['cron_period'] = ''; $cron_data[1] = $that->post; $updateArray['data'] = serialize($cron_data); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $that->get['job_id'], $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); } } if (is_numeric($that->get['job_id'])) { // load the job $str = "SELECT * from tx_multishop_import_jobs where id='" . $that->get['job_id'] . "'" . ' and type=\'' . addslashes($params['importKey']) . '\''; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $jobArray = $row; $data = unserialize($row['data']); // copy the previous post data to the current post so it can run the // job again $that->post = $data[1]; if ($row['categories_id']) { $that->post['cid'] = $row['categories_id']; } // update the last run time $updateArray = array(); $updateArray['last_run'] = time(); $query = $GLOBALS['TYPO3_DB']->UPDATEquery('tx_multishop_import_jobs', 'id=' . $row['id'] . ' and type=\'' . addslashes($params['importKey']) . '\'', $updateArray); $res = $GLOBALS['TYPO3_DB']->sql_query($query); // update the last run time eof if ($log_file) { file_put_contents($log_file, $that->FULL_HTTP_URL . ' - cron job settings loaded.(' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND); } } if ($that->post['file_url']) { if (strstr($that->post['file_url'], "../")) { die; } $filename = time(); $file = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $filename; file_put_contents($file, mslib_fe::file_get_contents($that->post['file_url'])); } if ($that->post['filename']) { $file = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $that->post['filename']; } if ($that->post['database_name'] or $file) { if ($file) { $str = mslib_fe::file_get_contents($file); } if ($that->post['parser_template']) { $processed = 0; $rows = array(); /* if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['TmpproductImportParserTemplateProc'])) { $params=array( 'parser_template'=>&$that->post['parser_template'], 'prefix_source_name'=>$that->post['prefix_source_name'], 'str'=>$str, 'rows'=>&$rows, 'file_location'=>&$file, 'table_cols'=>&$table_cols, 'processed'=>&$processed ); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/scripts/admin_pages/admin_import.php']['TmpproductImportParserTemplateProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $that); } } */ } else { if ($str && mslib_befe::isSerializedString($str)) { $tmpData = unserialize($str); $counter = 0; foreach ($tmpData as $data) { $colCounter = 0; if ($counter == 0) { $row = array(); foreach ($data as $key => $val) { $row[] = $key; } $table_cols = $row; } $row = array(); foreach ($data as $key => $val) { $row[] = $val; } $rows[] = $row; $counter++; } } elseif ($that->post['database_name']) { if (is_numeric($that->get['limit'])) { $limit = $that->get['limit']; } else { $limit = 2000; } if (strstr(mslib_befe::strtolower($that->post['database_name']), 'select ')) { $that->databaseMode = 'query'; // its not a table name, its a full query $that->databaseMode = 'query'; $str = $that->post['database_name'] . ' LIMIT ' . $limit; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); if ($that->conf['debugEnabled'] == '1') { $logString = 'Load records for importer query: ' . $str; \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($logString, 'multishop', -1); } $datarows = array(); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) { $datarows[] = $row; } } else { // get primary key first $str = "show index FROM " . $that->post['database_name'] . ' where Key_name = \'PRIMARY\''; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry); $primaryKeyColumn = $row['Column_name']; $query = $GLOBALS['TYPO3_DB']->SELECTquery('*', $that->post['database_name'], '', '', '', $limit); $qry = $GLOBALS['TYPO3_DB']->sql_query($query); $datarows = array(); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) { $datarows[] = $row; if ($primaryKeyColumn and isset($row[$primaryKeyColumn])) { $str2 = "delete from " . $that->post['database_name'] . " where " . $primaryKeyColumn . "='" . $row[$primaryKeyColumn] . "'"; $qry2 = $GLOBALS['TYPO3_DB']->sql_query($str2); } } } $total_datarows = count($datarows); if ($that->msLogFile) { file_put_contents($that->msLogFile, $that->HTTP_HOST . ' - loaded (' . $total_datarows . ') records. (' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND); } $i = 0; $rows = array(); foreach ($datarows as $datarow) { $s = 0; foreach ($datarow as $datacol) { $rows[$i][$s] = $datacol; $s++; } $i++; } } elseif ($that->post['format'] == 'excel') { // excel $paths = array(); $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Resources/Private/Contributed/PHPExcel/IOFactory.php'; $paths[] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('phpexcel_service') . 'Classes/PHPExcel/IOFactory.php'; foreach ($paths as $path) { if (file_exists($path)) { require_once $path; break; } } $phpexcel = PHPExcel_IOFactory::load($file); foreach ($phpexcel->getWorksheetIterator() as $worksheet) { $counter = 0; foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(false); foreach ($cellIterator as $cell) { $clean_products_data = ltrim(rtrim($cell->getCalculatedValue(), " ,"), " ,"); $clean_products_data = trim($clean_products_data); if ($row->getRowIndex() > 1) { $rows[$counter - 1][] = $clean_products_data; } else { $table_cols[] = mslib_befe::strtolower($clean_products_data); } } $counter++; } } // excel eof } elseif ($that->post['format'] == 'xml') { $objXML = new xml2Array(); $arrOutput = $objXML->parse($str); $i = 0; $s = 0; $rows = array(); foreach ($arrOutput[0]['children'] as $item) { // image foreach ($item['children'] as $internalitem) { $rows[$i][$s] = $internalitem['tagData']; $s++; } foreach ($item['attrs'] as $key => $value) { $rows[$i][$s] = $value; $s++; } $i++; $s = 0; } } else { if ($that->post['os'] == 'linux') { $splitter = "\n"; } else { $splitter = "\r\n"; } $str = trim($str, $splitter); if ($that->post['escape_first_line']) { $pos = strpos($str, $splitter); $str = substr($str, $pos + strlen($splitter)); } // csv if ($that->post['delimiter'] == "tab") { $delimiter = "\t"; } elseif ($that->post['delimiter'] == "dash") { $delimiter = "|"; } elseif ($that->post['delimiter'] == "dotcomma") { $delimiter = ";"; } elseif ($that->post['delimiter'] == "comma") { $delimiter = ","; } else { $delimiter = "\t"; } if ($that->post['backquotes']) { $backquotes = '"'; } else { $backquotes = '"'; } if ($that->post['format'] == 'txt') { $row = 1; $rows = array(); if (($handle = fopen($file, "r")) !== false) { $counter = 0; while (($data = fgetcsv($handle, '', $delimiter, $backquotes)) !== false) { if ($that->post['escape_first_line']) { if ($counter == 0) { $table_cols = $data; } else { $rows[] = $data; } } else { $rows[] = $data; } $counter++; } fclose($handle); } } // csv } } $item_counter = 0; $inserteditems = array(); $global_start_time = microtime(true); $start_time = microtime(true); $total_datarows = count($rows); if ($that->msLogFile) { if ($total_datarows) { // sometimes the preload takes so long that the database connection is lost. $GLOBALS['TYPO3_DB']->connectDB(); file_put_contents($that->msLogFile, $that->HTTP_HOST . ' - ' . $params['importKey'] . ' importer loaded, now starting the import. (' . date("Y-m-d G:i:s") . ")\n", FILE_APPEND); } else { file_put_contents($that->msLogFile, $that->HTTP_HOST . ' - no records needed to be imported' . "\n", FILE_APPEND); } } // $global_start_time = microtime(); foreach ($rows as $row) { foreach ($row as $key => $col) { if (!mb_detect_encoding($col, 'UTF-8', true)) { if ($col == 'NULL' || $col == 'null') { $col = ''; } $row[$key] = mslib_befe::convToUtf8($col); } } $that->ms['target-cid'] = $that->post['cid']; $teller++; if ($that->post['escape_first_line'] and $teller > 1 or !$that->post['escape_first_line']) { $tmpitem = $row; $cols = count($tmpitem); $flipped_select = array_flip($that->post['select']); // if($tmpitem[$that->post['select'][0]] and $cols > 0) // { $item = array(); // if the source is a database table name add the unique id // so we can delete it after the import if ($that->post['database_name']) { $item['table_unique_id'] = $row[0]; } // aux $input = array(); // name for ($i = 0; $i < $cols; $i++) { $tmpitem[$i] = trim($tmpitem[$i]); $char = ''; $item[$that->post['select'][$i]] = $tmpitem[$i]; if ($item[$that->post['select'][$i]] == $char and $char) { $item[$that->post['select'][$i]] = ''; } $input[$that->post['select'][$i]] = $that->post['input'][$i]; } if ($jobArray['predefined_variables']) { $array = unserialize($jobArray['predefined_variables']); foreach ($array as $col => $val) { $item[$col] = $val; } } // custom hook that can be controlled by third-party plugin if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_admin_import.php']['msAdminImportItemIterateProc'])) { $params = array('importKey' => &$params['importKey'], 'row' => &$row, 'item' => &$item, 'prefix_source_name' => $that->post['prefix_source_name'], 'params' => &$params, 'content' => &$content); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.tx_mslib_admin_import.php']['msAdminImportItemIterateProc'] as $funcRef) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $that); } } } if ($log_file) { $content = ''; } // end foreach } // if($file_location and file_exists($file_location)) // @unlink($file_location); } } // end import } else { $that->ms['show_default_form'] = 1; } if ($that->ms['show_default_form']) { $that->ms['upload_' . $params['importKey'] . 'feed_form'] .= self::renderImportJobProperties($params, $that); $content .= '<div class="panel-body"><form action="' . $params['postForm']['actionUrl'] . '" method="post" enctype="multipart/form-data" name="form1" id="form1" class="form-horizontal">'; $content .= $that->ms['upload_' . $params['importKey'] . 'feed_form']; $content .= '</form>'; // load the jobs templates $str = "SELECT * from tx_multishop_import_jobs where page_uid='" . $that->shop_pid . "' and type='" . addslashes($params['importKey']) . "' order by prefix_source_name asc, id desc"; $qry = $GLOBALS['TYPO3_DB']->sql_query($str); $jobs = array(); while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) != false) { $jobs[] = $row; } if (count($jobs) > 0) { $schedule_content .= ' <div class="panel panel-default" id="scheduled_import_jobs_form"><div class="panel-heading"><h3>' . $that->pi_getLL('import_tasks') . '</h3></div> <div class="panel-body"> <table class="table table-striped table-bordered no-mb" id="msAdminImportTableInterface"> <thead> <tr> <th>' . $that->pi_getLL('source_name') . '</th> <th class="cellName">' . $that->pi_getLL('name') . '</th> <th class="cellDate">' . $that->pi_getLL('last_run') . '</th> <th>' . $that->pi_getLL('action') . '</th> <th class="cellStatus">' . ucfirst($that->pi_getLL('status')) . '</th> <th class="cellAction">' . ucfirst($that->pi_getLL('delete')) . '</th> <th class="cellStatus">' . $that->pi_getLL('file_exists') . '</th> <th>' . $that->pi_getLL('upload_file') . '</th> <th>' . $that->pi_getLL('download_import_task') . '</th> </tr> </thead> '; $switch = ''; $schedule_content .= '<tbody>'; foreach ($jobs as $job) { if ($switch == 'odd') { $switch = 'even'; } else { $switch = 'odd'; } $schedule_content .= '<tr class="' . $switch . '">'; $schedule_content .= '<td>' . $job['prefix_source_name'] . '</td> <td class="cellName"><a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&action=edit_job">' . $job['name'] . '</a></td> '; $lastRun = ''; if ($job['last_run'] > 0) { $lastRun = date("Y-m-d", $job['last_run']) . '<br />' . date("G:i:s", $job['last_run']); } $schedule_content .= '<td class="cellDate">' . $lastRun . '</td>'; if (!$job['period']) { $schedule_content .= '<td>manual<br /><a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&action=run_job&limit=99999999" class="btn btn-success" onClick="return CONFIRM(\'' . addslashes($that->pi_getLL('are_you_sure_you_want_to_run_the_import_job')) . ': ' . htmlspecialchars(addslashes($job['name'])) . '?\')"><i>' . $that->pi_getLL('run_now') . '</i></a><br /><a href="" class="copy_to_clipboard" rel="' . htmlentities('/usr/bin/wget -O /dev/null --tries=1 --timeout=30 -q "' . $that->FULL_HTTP_URL . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&code=' . $job['code'] . '&action=run_job&run_as_cron=1&limit=99999999" >/dev/null 2>&1') . '" ><i>' . $that->pi_getLL('run_by_crontab') . '</i></a></td>'; } else { $schedule_content .= '<td>' . date("Y-m-d G:i:s", $job['last_run'] + $job['period']) . '</td>'; } $schedule_content .= '<td class="cellStatus">'; if (!$job['status']) { $schedule_content .= '<span class="admin_status_red" alt="Disable"></span>'; $schedule_content .= '<a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&status=1"><span class="admin_status_green disabled" alt="Enabled"></span></a>'; } else { $schedule_content .= '<a href="' . $params['postForm']['actionUrl'] . '&job_id=' . $job['id'] . '&status=0"><span class="admin_status_red disabled" alt="Disabled"></span></a>'; $schedule_content .= '<span class="admin_status_green" alt="Enable"></span>'; } $schedule_content .= '</td> <td class="cellAction"> <a href="' . $params['postForm']['actionUrl'] . '&delete=1&&job_id=' . $job['id'] . '&action=delete_job" onClick="return CONFIRM(\'Are you sure you want to delete the import job: ' . htmlspecialchars($job['name']) . '?\')" alt="Remove ' . htmlspecialchars($job['name']) . '" class="btn btn-danger btn-sm admin_menu_remove" title="Remove ' . htmlspecialchars($job['name']) . '"><i class="fa fa-trash-o"></i></a> </td> <td class="cellStatus"> '; $data = unserialize($job['data']); if ($data[1]['filename']) { $file_location = $that->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $data[1]['filename']; if (file_exists($file_location)) { $schedule_content .= '<span class="admin_status_green" alt="Enable"></span>'; } else { $schedule_content .= '<span class="admin_status_red" alt="Disable"></span>'; } } $schedule_content .= ' </td> <td> <form action="' . $params['postForm']['actionUrl'] . '" method="post" enctype="multipart/form-data" name="form1" id="form1"> <div class="input-group"> <input type="file" name="file" class="form-control" style="width:300px" /> <input name="skip_import" type="hidden" value="1" /> <input name="preProcExistingTask" type="hidden" value="1" /> <input name="job_id" type="hidden" value="' . $job['id'] . '" /> <input name="action" type="hidden" value="edit_job" /> <span class="input-group-btn"> <input type="submit" name="Submit" class="submit btn btn-success" id="cl_submit" value="' . $that->pi_getLL('upload') . '" /> </span> </div> </form> </td> <td> <a href="' . $params['postForm']['actionUrl'] . '&download=task&job_id=' . $job['id'] . '" class="btn btn-success"><i class="fa fa-download"></i> ' . $that->pi_getLL('download_import_task') . '</a> </td> '; $schedule_content .= '</tr>'; } $schedule_content .= '</tbody>'; $schedule_content .= '</table> </div> </div> <script type="text/javascript"> jQuery(document).ready(function($) { $(".copy_to_clipboard").click(function(event) { event.preventDefault(); var string=$(this).attr("rel"); $.blockUI({ theme: true, title: \'' . addslashes($that->pi_getLL('copy_below_text_and_add_it_to_crontab')) . '\', message: \'<p>\'+string+\'</p>\', timeout: 8000 }); }); }); </script> '; $tmptab = ''; $content .= $schedule_content; //$tabs['tasks']=array($that->pi_getLL('import_tasks'),$schedule_content); } // load the jobs templates eof if ($this->ROOTADMIN_USER) { $content .= ' <div id="scheduled_import_jobs_form" class="panel panel-default"> <div class="panel-heading"><h3>' . $that->pi_getLL('upload_import_task') . '</h3></div> <div class="panel-body"> <form action="' . $params['postForm']['actionUrl'] . '&upload=task" method="post" enctype="multipart/form-data" name="upload_task" id="upload_task" class="form-horizontal blockSubmitForm"> <div class="form-group"> <label for="new_cron_name" class="control-label col-md-2">' . $that->pi_getLL('name') . '</label> <div class="col-md-10"> <input name="new_cron_name" type="text" class="form-control" value="" size="125"> </div> </div> <div class="form-group"> <label for="new_prefix_source_name" class="control-label col-md-2">' . $that->pi_getLL('source_name') . '</label> <div class="col-md-10"> <input name="new_prefix_source_name" type="text" class="form-control" value="" /> </div> </div> <div class="form-group"> <label for="upload_task_file" class="control-label col-md-2">' . $that->pi_getLL('file') . '</label> <div class="col-md-10"> <input type="file" name="task_file" class="form-control"> </div> </div> <div class="form-group"> <div class="col-md-10 col-md-offset-2"> <input type="submit" name="upload_task_file" class="submit btn btn-success" id="upload_task_file" value="upload"> </div> </div> </form> </div> </div>'; } } $content .= '<hr><div class="clearfix"><a class="btn btn-success msAdminBackToCatalog" href="' . mslib_fe::typolink() . '"><span class="fa-stack"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-arrow-left fa-stack-1x"></i></span> ' . $that->pi_getLL('admin_close_and_go_back_to_catalog') . '</a></div></div>'; $content = '<div class="panel panel-default">' . mslib_fe::shadowBox($content) . '</div>'; return $content; }
$folder = mslib_befe::getImagePrefixFolder($record['products_image' . $cur]); $source_file = $this->DOCUMENT_ROOT . $this->ms['image_paths']['products']['original'] . '/' . $folder . '/' . $record['products_image' . $cur]; if (file_exists($source_file)) { copy($source_file, PATH_site . 'uploads/tx_multishop/tmp/' . $backup_folder . '/images/products/' . $record['products_image' . $cur]); } } } } // copy the products images to the backup folder eof } if (!file_put_contents(PATH_site . 'uploads/tx_multishop/tmp/' . $backup_folder . '/data.sql', $output)) { die(PATH_site . 'uploads/tx_multishop/tmp/' . $backup_folder . '/data.sql is not writable.'); } else { $backup_file = date("Y-m-d_G-i-s"); if ($this->zipPack(PATH_site . 'uploads/tx_multishop/tmp/' . $backup_folder . '/', PATH_site . 'uploads/tx_multishop/tmp/' . $backup_folder . '/' . $backup_file . '.zip')) { $output = mslib_fe::file_get_contents(PATH_site . 'uploads/tx_multishop/tmp/' . $backup_folder . '/' . $backup_file . '.zip'); $content = ob_get_contents(); // now remove the backup folder if ($backup_folder) { $tmp = $this->deltree(PATH_site . 'uploads/tx_multishop/tmp/' . $backup_folder); } ob_end_clean(); header('Content-Disposition: attachment; filename="' . $backup_file . '.t3xms"'); echo $output; exit; } else { die('Backupping failed (can\'t create the compressed backup file).'); } } } // backup database eof
$this->post['selected_invoices'] = $this->get['selected_invoices']; } $postErno = array(); switch ($this->post['tx_multishop_pi1']['action']) { case 'download_selected_invoices': case 'mail_selected_invoices_to_merchant': // send invoices by mail if (is_array($this->post['selected_invoices']) and count($this->post['selected_invoices'])) { $attachments = array(); foreach ($this->post['selected_invoices'] as $invoice) { if (is_numeric($invoice)) { $invoice = mslib_fe::getInvoice($invoice, 'id'); if ($invoice['id']) { // invoice as attachment $invoice_path = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . $invoice['invoice_id'] . '.pdf'; $invoice_data = mslib_fe::file_get_contents($this->FULL_HTTP_URL . mslib_fe::typolink($this->shop_pid . ',2002', 'tx_multishop_pi1[page_section]=download_invoice&tx_multishop_pi1[hash]=' . $invoice['hash'])); // write temporary to disk file_put_contents($invoice_path, $invoice_data); $attachments[$invoice['invoice_id']] = $invoice_path; } else { $postErno[] = array('status' => 'error', 'message' => 'Failed to retrieve invoice record id ' . $invoice); } } } if (count($attachments)) { // combine all PDF files in 1 (needs GhostScript on the server: yum install ghostscript) $combinedPdfFile = $this->DOCUMENT_ROOT . 'uploads/tx_multishop/tmp/' . time() . '_' . uniqid() . '.pdf'; $prog = \TYPO3\CMS\Core\Utility\CommandUtility::exec('which gs'); //hook to let other plugins further manipulate the settings if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/pi1/classes/class.mslib_befe.php']['overrideGhostScripPath'])) { $params = array('prog' => &$prog);