function psmHelperIntegrateFile($target, $modules) { $version = ''; $origin = ''; $files = array(); foreach ($modules as $module) { $file = _PS_MODULE_DIR_ . $module . '/' . $target; if (file_exists($file)) { $content = Tools::file_get_contents($file); $ver = ($start = strpos($content, 'PSM_VERSION[')) !== false && ($end = strpos($content, ']', $start)) !== false ? Tools::substr($content, $start + 12, $end - $start - 12) : false; if ($ver && Tools::version_compare($ver, $version, '>')) { $version = $ver; $origin = $file; } $files[$file] = $ver; } } foreach ($files as $file => $ver) { if (Tools::version_compare($version, $ver, '>') && $origin != $file) { Tools::copy($origin, $file); } } }
public static function importFileSelectColumn(array $file, $media, $campaign_id, $module_name) { switch ((string) $media) { case 'sms': $media_letter = 'S'; $redirect_step = 3; break; case 'fax': $media_letter = 'F'; $redirect_step = 4; break; default: Tools::redirectAdmin('index.php?controller=AdminMarketingX&token=' . Tools::getAdminTokenLite('AdminMarketingX')); exit; } $error = $file['error']; if ($error === 0) { $file_path = $file['tmp_name']; $file_copy = _PS_MODULE_DIR_ . (string) $module_name . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . basename($file_path) . '_copy.csv'; if (file_exists($file_path)) { Tools::copy($file_path, $file_copy); } else { return false; } Db::getInstance()->update('expressmailing_' . $media, array('campaign_date_update' => date('Y-m-d H:i:s'), 'path_to_import' => str_replace('\\', '/', $file_copy)), 'campaign_id = ' . (int) $campaign_id); Tools::redirectAdmin('index.php?controller=AdminMarketing' . $media_letter . 'Step' . $redirect_step . '&campaign_id=' . (int) $campaign_id . '&token=' . Tools::getAdminTokenLite('AdminMarketing' . $media_letter . 'Step' . $redirect_step)); exit; } return false; }
function copyImg15($id_entity, $id_image = null, $url, $entity = 'products') { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); //fichier tempo vide $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); switch ($entity) { default: case 'products': $image_obj = new Image($id_image); $path = $image_obj->getPathForCreation(); break; case 'categories': $path = _PS_CAT_IMG_DIR_ . (int) $id_entity; break; } $url = str_replace(' ', '%20', trim($url)); // Evaluate the memory required to resize the image: if it's too much, you can't resize it. if (!ImageManager::checkImageMemoryLimit($url)) { return false; } //Echo("in routine url, before the copy"); // 'file_exists' doesn't work on distant file, and getimagesize make the import slower. // Just hide the warning, the traitment will be the same. //echo(" - Copy image to:".$tmpfile." and then resize in :".$path); echo " register_globals: " . ini_get('register_globals'); echo " safe_mode: " . ini_get('safe_mode'); echo " allow_url_fopen: " . ini_get('allow_url_fopen'); //if(isset($sourceFile)) //{ //$array_img = explode('/',$sourceFile); //} //if(copy($_POST['source'],"img/".end($array_img))){ //echo(" - Copy ".$sourceFile." image to:"._PS_IMG_DIR_.end($array_img)." and then resize in :".$path); //if(copy($sourceFile,_PS_IMG_DIR_.end($array_img))) if ($version < 16000) { if (@copy($url, $tmpfile)) { ImageManager::resize($tmpfile, $path . '.jpg'); //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'.jpg'); $images_types = ImageType::getImagesTypes($entity); foreach ($images_types as $image_type) { ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']); } //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']); if (in_array($image_type['id_image_type'], $watermark_types)) { Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } else { echo " - @copy failed, please check Apache parameters like safe_mode=off, register_globals=off, allows_url_fopen=true and writting right in /img/tmp and img/p folders"; unlink($tmpfile); return false; } } else { if (Tools::copy($url, $tmpfile)) { ImageManager::resize($tmpfile, $path . '.jpg'); //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'.jpg'); $images_types = ImageType::getImagesTypes($entity); foreach ($images_types as $image_type) { ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']); } //ImageManager::resize(_PS_IMG_DIR_.end($array_img), $path.'-'.stripslashes($image_type['name']).'.jpg', $image_type['width'], $image_type['height']); if (in_array($image_type['id_image_type'], $watermark_types)) { Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } else { echo " - @copy failed, please check Apache parameters like safe_mode=off, register_globals=off, allows_url_fopen=true and writting right in /img/tmp and img/p folders"; unlink($tmpfile); return false; } } unlink($tmpfile); return true; }
public function duplicate() { if (!Validate::isLoadedObject($this)) { return false; } $cart = new Cart($this->id); $cart->id = null; $cart->id_shop = $this->id_shop; $cart->id_shop_group = $this->id_shop_group; if (!Customer::customerHasAddress((int) $cart->id_customer, (int) $cart->id_address_delivery)) { $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId((int) $cart->id_customer); } if (!Customer::customerHasAddress((int) $cart->id_customer, (int) $cart->id_address_invoice)) { $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId((int) $cart->id_customer); } if ($cart->id_customer) { $cart->secure_key = Cart::$_customer->secure_key; } $cart->add(); if (!Validate::isLoadedObject($cart)) { return false; } $success = true; $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'cart_product` WHERE `id_cart` = ' . (int) $this->id); $product_gift = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT cr.`gift_product`, cr.`gift_product_attribute` FROM `' . _DB_PREFIX_ . 'cart_rule` cr LEFT JOIN `' . _DB_PREFIX_ . 'order_cart_rule` ocr ON (ocr.`id_order` = ' . (int) $this->id . ') WHERE ocr.`id_cart_rule` = cr.`id_cart_rule`'); $id_address_delivery = Configuration::get('PS_ALLOW_MULTISHIPPING') ? $cart->id_address_delivery : 0; foreach ($products as $product) { if ($id_address_delivery) { if (Customer::customerHasAddress((int) $cart->id_customer, $product['id_address_delivery'])) { $id_address_delivery = $product['id_address_delivery']; } } foreach ($product_gift as $gift) { if (isset($gift['gift_product']) && isset($gift['gift_product_attribute']) && (int) $gift['gift_product'] == (int) $product['id_product'] && (int) $gift['gift_product_attribute'] == (int) $product['id_product_attribute']) { $product['quantity'] = (int) $product['quantity'] - 1; } } $success &= $cart->updateQty((int) $product['quantity'], (int) $product['id_product'], (int) $product['id_product_attribute'], null, 'up', (int) $id_address_delivery, new Shop((int) $cart->id_shop), false); } // Customized products $customs = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT * FROM ' . _DB_PREFIX_ . 'customization c LEFT JOIN ' . _DB_PREFIX_ . 'customized_data cd ON cd.id_customization = c.id_customization WHERE c.id_cart = ' . (int) $this->id); // Get datas from customization table $customs_by_id = array(); foreach ($customs as $custom) { if (!isset($customs_by_id[$custom['id_customization']])) { $customs_by_id[$custom['id_customization']] = array('id_product_attribute' => $custom['id_product_attribute'], 'id_product' => $custom['id_product'], 'quantity' => $custom['quantity']); } } // Insert new customizations $custom_ids = array(); foreach ($customs_by_id as $customization_id => $val) { Db::getInstance()->execute(' INSERT INTO `' . _DB_PREFIX_ . 'customization` (id_cart, id_product_attribute, id_product, `id_address_delivery`, quantity, `quantity_refunded`, `quantity_returned`, `in_cart`) VALUES(' . (int) $cart->id . ', ' . (int) $val['id_product_attribute'] . ', ' . (int) $val['id_product'] . ', ' . (int) $id_address_delivery . ', ' . (int) $val['quantity'] . ', 0, 0, 1)'); $custom_ids[$customization_id] = Db::getInstance(_PS_USE_SQL_SLAVE_)->Insert_ID(); } // Insert customized_data if (count($customs)) { $first = true; $sql_custom_data = 'INSERT INTO ' . _DB_PREFIX_ . 'customized_data (`id_customization`, `type`, `index`, `value`) VALUES '; foreach ($customs as $custom) { if (!$first) { $sql_custom_data .= ','; } else { $first = false; } $customized_value = $custom['value']; if ((int) $custom['type'] == 0) { $customized_value = md5(uniqid(rand(), true)); Tools::copy(_PS_UPLOAD_DIR_ . $custom['value'], _PS_UPLOAD_DIR_ . $customized_value); Tools::copy(_PS_UPLOAD_DIR_ . $custom['value'] . '_small', _PS_UPLOAD_DIR_ . $customized_value . '_small'); } $sql_custom_data .= '(' . (int) $custom_ids[$custom['id_customization']] . ', ' . (int) $custom['type'] . ', ' . (int) $custom['index'] . ', \'' . pSQL($customized_value) . '\')'; } Db::getInstance()->execute($sql_custom_data); } return array('cart' => $cart, 'success' => $success); }
/** * PROCESS : installFixtures * Install fixtures (E.g. demo products) */ public function installFixtures($entity = null, array $data = array()) { $fixtures_path = _PS_INSTALL_FIXTURES_PATH_ . 'apple/'; $fixtures_name = 'apple'; $zip_file = _PS_ROOT_DIR_ . '/download/fixtures.zip'; $temp_dir = _PS_ROOT_DIR_ . '/download/fixtures/'; // try to download fixtures if no low memory mode if ($entity === null) { if (Tools::copy('http://api.prestashop.com/fixtures/' . $data['shop_country'] . '/' . $data['shop_activity'] . '/fixtures.zip', $zip_file)) { Tools::deleteDirectory($temp_dir, true); if (Tools::ZipTest($zip_file)) { if (Tools::ZipExtract($zip_file, $temp_dir)) { $files = scandir($temp_dir); if (count($files)) { foreach ($files as $file) { if (!preg_match('/^\\./', $file) && is_dir($temp_dir . $file . '/')) { $fixtures_path = $temp_dir . $file . '/'; $fixtures_name = $file; break; } } } } } } } // Load class (use fixture class if one exists, or use InstallXmlLoader) if (file_exists($fixtures_path . '/install.php')) { require_once $fixtures_path . '/install.php'; $class = 'InstallFixtures' . Tools::toCamelCase($fixtures_name); if (!class_exists($class, false)) { $this->setError($this->language->l('Fixtures class "%s" not found', $class)); return false; } $xml_loader = new $class(); if (!$xml_loader instanceof InstallXmlLoader) { $this->setError($this->language->l('"%s" must be an instane of "InstallXmlLoader"', $class)); return false; } } else { $xml_loader = new InstallXmlLoader(); } // Install XML data (data/xml/ folder) $xml_loader->setFixturesPath($fixtures_path); if (isset($this->xml_loader_ids) && $this->xml_loader_ids) { $xml_loader->setIds($this->xml_loader_ids); } $languages = array(); foreach (Language::getLanguages(false) as $lang) { $languages[$lang['id_lang']] = $lang['iso_code']; } $xml_loader->setLanguages($languages); if ($entity) { $xml_loader->populateEntity($entity); } else { $xml_loader->populateFromXmlFiles(); Tools::deleteDirectory($temp_dir, true); @unlink($zip_file); } if ($errors = $xml_loader->getErrors()) { $this->setError($errors); return false; } // IDS from xmlLoader are stored in order to use them for fixtures $this->xml_loader_ids = $xml_loader->getIds(); unset($xml_loader); // Index products in search tables Search::indexation(true); return true; }
public static function installExternalCarrier($config) { $carrier = new Carrier(); $carrier->hydrate($config); $carrier->name = $config['name']; $carrier->id_zone = $config['id_zone']; $carrier->active = $config['active']; $carrier->deleted = $config['deleted']; $carrier->delay = $config['delay']; $carrier->shipping_handling = $config['shipping_handling']; $carrier->range_behavior = $config['range_behavior']; $carrier->is_module = $config['is_module']; $carrier->shipping_external = $config['shipping_external']; $carrier->external_module_name = $config['external_module_name']; $carrier->need_range = $config['need_range']; $carrier->setTaxRulesGroup($config['id_tax_rules_group'], true); $languages = Language::getLanguages(true); foreach ($languages as $language) { if ($language['iso_code'] == 'lv') { $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']]; } if ($language['iso_code'] == 'lt') { $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']]; } if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'))) { $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']]; } } if ($carrier->add()) { $groups = Group::getGroups(true); foreach ($groups as $group) { Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT'); } // $range_price = new RangePrice(); // $range_price->id_carrier = $carrier->id; // $range_price->delimiter1 = '0'; // $range_price->delimiter2 = '10000'; // $range_price->add(); // $range_weight = new RangeWeight(); // $range_weight->id_carrier = $carrier->id; // $range_weight->delimiter1 = '0'; // $range_weight->delimiter2 = '10000'; // $range_weight->add(); // Add weight ranges to carrier $rangePrices = array(); foreach ($config['ranges'] as $range) { $rangeWeight = new RangeWeight(); $rangeWeight->hydrate(array('id_carrier' => $carrier->id, 'delimiter1' => (double) $range['delimiter1'], 'delimiter2' => (double) $range['delimiter2'])); $rangeWeight->add(); // Save range ID and price and set it after the Zones have been added $rangePrices[] = array('id_range_weight' => $rangeWeight->id, 'price' => $range['price']); } // Update prices in delivery table for each range (need IDs) foreach ($rangePrices as $rangePrice) { $data = array('price' => $rangePrice['price']); $where = 'id_range_weight = ' . $rangePrice['id_range_weight']; Db::getInstance()->update('delivery', $data, $where); } // Add Europe for EVERY carrier range // Automatically creates rows in delivery table, price is 0 $id_zone_europe = Zone::getIdByName('Europe'); $carrier->addZone($id_zone_europe ? $id_zone_europe : 1); // Copy Logo if (!Tools::copy(dirname(__FILE__) . '/logo.png', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.png')) { return false; } DpdCarrierOptions::setCarrierOptions((int) $carrier->id, (int) $carrier->id, $config['type']); // Return ID Carrier return (int) $carrier->id; } return false; }
$product_has_images = (bool) Image::getImages($id_lang, $product->id); $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = !$product_has_images ? true : false; $field_error = $image->validateFields(UNFRIENDLY_ERROR, true); $lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true); $id_shop_list = array(); $errors = array(); $warnings = array(); $id_shop_list[] = $product->id_shop_default; if ($image->add()) { $image->associateTo($id_shop_list); $image->getPathForCreation(); $image_final = $image->getPathForCreation() . '.jpg'; if (Tools::copy($url, $image_final)) { $tgt_width = $tgt_height = 0; $src_width = $src_height = 0; $previous_path = null; $path_infos = array(); $images_types = ImageType::getImagesTypes('products', true); foreach ($images_types as $image_type) { if (ImageManager::resize($image_final, $image->getPathForCreation() . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height'], 'jpg', false, $error, $tgt_width, $tgt_height, 5, $src_width, $src_height)) { if (is_file(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '.jpg')) { unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '.jpg'); } if (is_file(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '_' . (int) Context::getContext()->shop->id . '.jpg')) { unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product->id . '_' . (int) Context::getContext()->shop->id . '.jpg'); } } }
public function createNewOrderStates() { $order_states = $this->getMediafinanzOrderStates(); //check shop for custom order states foreach ($order_states as $order_state_key => $order_state) { $create_os = false; $create_os_id = 0; if ((int) Configuration::get($order_state_key) > 0) { $os = new OrderState((int) Configuration::get($order_state_key)); if (!Validate::isLoadedObject($os)) { $create_os = true; $create_os_id = (int) Configuration::get($order_state_key); } } else { $create_os = true; } if ($create_os == true) { $os = new OrderState(); if ($create_os_id > 0) { $os->id = $create_os_id; } $langs = Language::getLanguages(); foreach ($langs as $lang) { $os->name[$lang['id_lang']] = $order_state['name']; $os->template[$lang['id_lang']] = $order_state['template']; } $os->color = $order_state['color']; $os->send_email = $order_state['send_email']; $os->unremovable = 1; $os->hidden = 0; $os->logable = 0; $os->delivery = 0; $os->shipped = 0; $os->paid = 0; $os->pdf_invoice = 1; $os->module_name = $this->name; if ($os->add()) { $source = dirname(__FILE__) . '/../../img/os/' . Configuration::get('PS_OS_CHEQUE') . '.gif'; $destination = dirname(__FILE__) . '/../../img/os/' . (int) $os->id . '.gif'; Tools::copy($source, $destination); } Configuration::updateValue($order_state_key, $os->id); } } return true; }
/** * Copy a remote or local file to the local campaign storage * @param string $url * @param string $filename The name of the resulting file * @return mixed Null if fail or a string containing the path of the resulting image. */ private function copyFileToStorage($url, $filename = null) { $dest = $this->module->getPreviewFolder(); $dest .= $this->campaign_id . DIRECTORY_SEPARATOR; if (!Tools::file_exists_no_cache($dest)) { mkdir($dest, 0777, true); Tools::copy(_PS_MODULE_DIR_ . 'expressmailing/index.php', $dest . 'index.php'); } if ($filename) { $dest .= (string) $filename; } else { $dest .= basename((string) $url); } $dest = urldecode($dest); $dest = str_replace(' ', '_', $dest); $dest = EMTools::removeAccents($dest); if (($pos = strpos($dest, '?')) !== false) { $dest = Tools::substr($dest, 0, $pos); } if (function_exists('curl_version')) { $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Mozilla/5.0'; $ch = curl_init((string) $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_CRLF, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $raw = curl_exec($ch); curl_close($ch); if (file_exists($dest)) { unlink($dest); } $fp = fopen($dest, 'x'); fwrite($fp, $raw); fclose($fp); if (file_exists($dest)) { return $dest; } } else { if (Tools::copy((string) $url, $dest)) { return $dest; } } return null; }
public static function installModuleTab($module_name, $title, $class_sfx = '', $parent = '') { $class = 'Admin' . Tools::ucfirst($module_name) . Tools::ucfirst($class_sfx); @Tools::copy(_PS_MODULE_DIR_ . $module_name . '/logo.gif', _PS_IMG_DIR_ . 't/' . $class . '.gif'); if ($parent == '') { $position = Tab::getCurrentTabId(); } else { $position = Tab::getIdFromClassName($parent); } $tab1 = new Tab(); $tab1->class_name = $class; $tab1->module = $module_name; $tab1->id_parent = call_user_func('int' . 'val', $position); $langs = Language::getLanguages(false); foreach ($langs as $l) { $tab1->name[$l['id_lang']] = $title; } if ($parent == -1) { $tab1->id_parent = -1; $id_tab1 = $tab1->add(); } else { $id_tab1 = $tab1->add(true, false); } unset($id_tab1); }
/** * Create Backup file of changing content * * @param string $target patch to file * @return boolean - true if success */ public function makeBackup($target = null) { if (empty($target)) { $target = $this->target; } $this->backup_time_stamp = time(); $parent = $target; $children = $target . $this->backup_prefix . $this->backup_time_stamp; if (!Tools::copy($parent, $children)) { $this->error_msg[] = error_get_last(); return false; } else { if (filesize($parent) === filesize($children)) { return true; } else { return false; } } }
/** * copyImg copy an image located in $url and save it in a path * according to $entity->$id_entity . * $id_image is used if we need to add a watermark * * @param int $id_entity id of product or category (set in entity) * @param int $id_image (default null) id of the image if watermark enabled. * @param string $url path or url to use * @param string entity 'products' or 'categories' * @return void */ protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products') { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); switch ($entity) { default: case 'products': $image_obj = new Image($id_image); $path = $image_obj->getPathForCreation(); break; case 'categories': $path = _PS_CAT_IMG_DIR_ . (int) $id_entity; break; } $url = str_replace(' ', '%20', trim($url)); // Evaluate the memory required to resize the image: if it's too much, you can't resize it. if (!ImageManager::checkImageMemoryLimit($url)) { return false; } // 'file_exists' doesn't work on distant file, and getimagesize make the import slower. // Just hide the warning, the traitment will be the same. if (Tools::copy($url, $tmpfile)) { ImageManager::resize($tmpfile, $path . '.jpg'); $images_types = ImageType::getImagesTypes($entity); foreach ($images_types as $image_type) { ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']); } if (in_array($image_type['id_image_type'], $watermark_types)) { Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } else { unlink($tmpfile); return false; } unlink($tmpfile); return true; }
/** * downloadLast download the last version of PrestaShop and save it in $dest/$filename * * @param string $dest directory where to save the file * @param string $filename new filename * @return boolean * * @TODO ftp if copy is not possible (safe_mode for example) */ public function downloadLast($dest, $filename = 'prestashop.zip') { if (empty($this->link)) { $this->checkPSVersion(); } $destPath = realpath($dest) . DIRECTORY_SEPARATOR . $filename; Tools::copy($this->link, $destPath); return is_file($destPath); }
function deployworker($arg) { $id = $arg['id']; $rootdir = $arg['rootdir']; $dirs = $arg['dirs']; $remote = $arg['remote']; //! call rsync $files = []; if (substr($rootdir, -1) != "/") { $rootdir .= "/"; } foreach ($dirs as $d) { $files[$rootdir . $d] = 1; } Core::$user->data['remote'] = $remote; $files = array_keys($files); $path = !empty($remote['path']) ? $remote['path'] : "/var/www/"; if (!empty($arg['rsync'])) { $ret = Tools::ssh("rsync", $files, $path); } else { $ret = Tools::copy($files, $path); } //! update status DS::exec("UPDATE " . self::$_table . " SET console=?,syncd=CURRENT_TIMESTAMP WHERE id=?", [$id]); }
public function processImportTheme() { $this->display = 'importtheme'; if ($this->context->mode == Context::MODE_HOST) { return true; } if (isset($_FILES['themearchive']) && isset($_POST['filename']) && Tools::isSubmit('theme_archive_server')) { $uniqid = uniqid(); $sandbox = _PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid . DIRECTORY_SEPARATOR; mkdir($sandbox); $archive_uploaded = false; if (Tools::getValue('filename') != '') { $uploader = new Uploader('themearchive'); $uploader->setAcceptTypes(array('zip')); $uploader->setSavePath($sandbox); $file = $uploader->process(Theme::UPLOADED_THEME_DIR_NAME . '.zip'); if ($file[0]['error'] === 0) { if (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) { $archive_uploaded = true; } else { $this->errors[] = $this->l('Zip file seems to be broken'); } } else { $this->errors[] = $file[0]['error']; } } elseif (Tools::getValue('themearchiveUrl') != '') { if (!Validate::isModuleUrl($url = Tools::getValue('themearchiveUrl'), $this->errors)) { $this->errors[] = $this->l('Only zip files are allowed'); } elseif (!Tools::copy($url, $sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) { $this->errors[] = $this->l('Error during the file download'); } elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) { $archive_uploaded = true; } else { $this->errors[] = $this->l('Zip file seems to be broken'); } } elseif (Tools::getValue('theme_archive_server') != '') { $filename = _PS_ALL_THEMES_DIR_ . Tools::getValue('theme_archive_server'); if (substr($filename, -4) != '.zip') { $this->errors[] = $this->l('Only zip files are allowed'); } elseif (!copy($filename, $sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) { $this->errors[] = $this->l('An error has occurred during the file copy.'); } elseif (Tools::ZipTest($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip')) { $archive_uploaded = true; } else { $this->errors[] = $this->l('Zip file seems to be broken'); } } else { $this->errors[] = $this->l('You must upload or enter a location of your zip'); } if ($archive_uploaded) { if ($this->extractTheme($sandbox . Theme::UPLOADED_THEME_DIR_NAME . '.zip', $sandbox)) { $this->installTheme(Theme::UPLOADED_THEME_DIR_NAME, $sandbox); } } Tools::deleteDirectory($sandbox); if (count($this->errors) > 0) { $this->display = 'importtheme'; } else { Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminThemes') . '&conf=18'); } } }
public static function copy($source, $destination, $stream_context = null) { ${"GLOBALS"}["oxlohp"] = "source"; ${"GLOBALS"}["slrevncrkelv"] = "stream_context"; $xoubvsmkhd = "destination"; $qopubtlqge = "source"; if (version_compare(_PS_VERSION_, "1.5.5", ">=")) { return Tools::copy(${${"GLOBALS"}["oxlohp"]}, ${$xoubvsmkhd}, ${${"GLOBALS"}["slrevncrkelv"]}); } if (${${"GLOBALS"}["pdpkxhbgsn"]} == null && preg_match("/^https?:\\/\\//", ${$qopubtlqge})) { ${${"GLOBALS"}["pdpkxhbgsn"]} = @stream_context_create(array("http" => array("timeout" => 10))); } if (in_array(@ini_get("allow_url_fopen"), array("On", "on", "1")) || !preg_match("/^https?:\\/\\//", ${${"GLOBALS"}["hhjgdp"]})) { return @copy(${${"GLOBALS"}["hhjgdp"]}, ${${"GLOBALS"}["snowmqz"]}, ${${"GLOBALS"}["pdpkxhbgsn"]}); } elseif (function_exists("curl_init")) { ${"GLOBALS"}["wugwrzf"] = "stream_context"; ${"GLOBALS"}["stjlqdayfxu"] = "curl"; ${"GLOBALS"}["wdqndeofewc"] = "source"; ${${"GLOBALS"}["ymbtitpcdb"]} = curl_init(); curl_setopt(${${"GLOBALS"}["ymbtitpcdb"]}, CURLOPT_RETURNTRANSFER, 1); curl_setopt(${${"GLOBALS"}["ymbtitpcdb"]}, CURLOPT_URL, ${${"GLOBALS"}["wdqndeofewc"]}); curl_setopt(${${"GLOBALS"}["ymbtitpcdb"]}, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt(${${"GLOBALS"}["ymbtitpcdb"]}, CURLOPT_TIMEOUT, 10); ${"GLOBALS"}["adqgwaurobp"] = "opts"; curl_setopt(${${"GLOBALS"}["ymbtitpcdb"]}, CURLOPT_SSL_VERIFYPEER, 0); ${${"GLOBALS"}["adqgwaurobp"]} = stream_context_get_options(${${"GLOBALS"}["wugwrzf"]}); $azcwlwnqo = "content"; $ajomliwecdh = "destination"; $velwhpsnqtg = "curl"; ${$azcwlwnqo} = curl_exec(${${"GLOBALS"}["stjlqdayfxu"]}); curl_close(${$velwhpsnqtg}); return file_put_contents(${$ajomliwecdh}, ${${"GLOBALS"}["vnaibglmrrc"]}); } else { return false; } }
/** * copyImg copy an image located in $url and save it in a path * according to $entity->$id_entity . * $id_image is used if we need to add a watermark * * @param int $id_entity id of product or category (set in entity) * @param int $id_image (default null) id of the image if watermark enabled. * @param string $url path or url to use * @param string entity 'products' or 'categories' * @return boolean */ protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products', $regenerate = true) { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); switch ($entity) { default: case 'products': $image_obj = new Image($id_image); $path = $image_obj->getPathForCreation(); break; case 'categories': $path = _PS_CAT_IMG_DIR_ . (int) $id_entity; break; case 'manufacturers': $path = _PS_MANU_IMG_DIR_ . (int) $id_entity; break; case 'suppliers': $path = _PS_SUPP_IMG_DIR_ . (int) $id_entity; break; } $url = str_replace(' ', '%20', trim($url)); $url = urldecode($url); $parced_url = parse_url($url); if (isset($parced_url['path'])) { $uri = ltrim($parced_url['path'], '/'); $parts = explode('/', $uri); foreach ($parts as &$part) { $part = urlencode($part); } unset($part); $parced_url['path'] = '/' . implode('/', $parts); } if (isset($parced_url['query'])) { $query_parts = array(); parse_str($parced_url['query'], $query_parts); $parced_url['query'] = http_build_query($query_parts); } if (!function_exists('http_build_url')) { require_once _PS_TOOL_DIR_ . 'http_build_url/http_build_url.php'; } $url = http_build_url('', $parced_url); // Evaluate the memory required to resize the image: if it's too much, you can't resize it. if (!ImageManager::checkImageMemoryLimit($url)) { return false; } // 'file_exists' doesn't work on distant file, and getimagesize makes the import slower. // Just hide the warning, the processing will be the same. if (Tools::copy($url, $tmpfile)) { ImageManager::resize($tmpfile, $path . '.jpg'); $images_types = ImageType::getImagesTypes($entity); if ($regenerate) { foreach ($images_types as $image_type) { ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']); if (in_array($image_type['id_image_type'], $watermark_types)) { Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } } } else { unlink($tmpfile); return false; } unlink($tmpfile); return true; }
function psmppropertiesIntegration($vars, $install) { Tools::deleteDirectory($vars['base']); if ($install) { if (file_exists($vars['base'])) { return array('error_delete_directory' => $vars['base']); } mkdir($vars['dirname'], 0755, true); Tools::copy(_PS_MODULE_DIR_ . $vars['module']->name . '/ppsetup.php', $vars['ppsetup']); PSM::protectDirectory($vars['base']); if (!is_file($vars['ppsetup'])) { return array('error_create_file' => $vars['ppsetup']); } } return true; }
public static function copy($source, $destination, $stream_context = null) { ${"GLOBALS"}["zscquywjscy"] = "destination"; $wegrcoprhcd = "source"; ${"GLOBALS"}["fbfmbge"] = "destination"; if (version_compare(_PS_VERSION_, "1.5.5", ">=")) { return Tools::copy(${$wegrcoprhcd}, ${${"GLOBALS"}["zscquywjscy"]}, ${${"GLOBALS"}["wgmtqeytnlh"]}); } ${"GLOBALS"}["xvwrwvc"] = "source"; if (${${"GLOBALS"}["wgmtqeytnlh"]} == null && preg_match("/^https?:\\/\\//", ${${"GLOBALS"}["jefdgtwy"]})) { ${${"GLOBALS"}["wgmtqeytnlh"]} = @stream_context_create(array("http" => array("timeout" => 10))); } if (in_array(@ini_get("allow_url_fopen"), array("On", "on", "1")) || !preg_match("/^https?:\\/\\//", ${${"GLOBALS"}["xvwrwvc"]})) { return @copy(${${"GLOBALS"}["jefdgtwy"]}, ${${"GLOBALS"}["fbfmbge"]}, ${${"GLOBALS"}["wgmtqeytnlh"]}); } elseif (function_exists("curl_init")) { $fjlfjiuoy = "content"; ${"GLOBALS"}["bkkkrgxouw"] = "curl"; ${"GLOBALS"}["hqdmkxxajues"] = "source"; $rggtrryaxv = "curl"; ${${"GLOBALS"}["lphylww"]} = curl_init(); ${"GLOBALS"}["vhpgygex"] = "curl"; ${"GLOBALS"}["ducfgs"] = "stream_context"; curl_setopt(${${"GLOBALS"}["lphylww"]}, CURLOPT_RETURNTRANSFER, 1); curl_setopt(${${"GLOBALS"}["vhpgygex"]}, CURLOPT_URL, ${${"GLOBALS"}["hqdmkxxajues"]}); curl_setopt(${${"GLOBALS"}["bkkkrgxouw"]}, CURLOPT_CONNECTTIMEOUT, 5); ${"GLOBALS"}["pqbmoimvtl"] = "opts"; curl_setopt(${${"GLOBALS"}["lphylww"]}, CURLOPT_TIMEOUT, 10); curl_setopt(${${"GLOBALS"}["lphylww"]}, CURLOPT_SSL_VERIFYPEER, 0); ${${"GLOBALS"}["pqbmoimvtl"]} = stream_context_get_options(${${"GLOBALS"}["ducfgs"]}); ${${"GLOBALS"}["gerinhppy"]} = curl_exec(${${"GLOBALS"}["lphylww"]}); curl_close(${$rggtrryaxv}); return file_put_contents(${${"GLOBALS"}["xkxnpim"]}, ${$fjlfjiuoy}); } else { return false; } }
private function restoreFile($file) { if (is_file($file)) { $dir = self::getBackupDirectory(); $rel_file = str_replace(_PS_ROOT_DIR_, '', $file); $backup_file = $dir . $rel_file; if (is_file($backup_file)) { Tools::copy($backup_file, $file); $timestamp = filemtime($backup_file); if ($timestamp !== false) { touch($file, $timestamp); } Tools::deleteFile($backup_file); } } }
/** * Install Module Tabs */ private function installModuleTab($title, $class_sfx = '', $parent = '') { $class = 'Admin' . Tools::ucfirst($this->name) . Tools::ucfirst($class_sfx); @Tools::copy(_PS_MODULE_DIR_ . $this->name . '/logo.gif', _PS_IMG_DIR_ . 't/' . $class . '.gif'); if ($parent == '') { # validate module $position = Tab::getCurrentTabId(); } else { # validate module $position = Tab::getIdFromClassName($parent); } $tab1 = new Tab(); $tab1->class_name = $class; $tab1->module = $this->name; $tab1->id_parent = (int) $position; $langs = Language::getLanguages(false); foreach ($langs as $l) { # validate module $tab1->name[$l['id_lang']] = $title; } if ($parent == -1) { $tab1->id_parent = -1; $tab1->add(); } else { $tab1->add(true, false); } }
/** * copyImg copy an image located in $url and save it in a path * according to $entity->$id_entity . * $id_image is used if we need to add a watermark * * @param int $id_entity id of product or category (set in entity) * @param int $id_image (default null) id of the image if watermark enabled. * @param string $url path or url to use * @param string $entity 'products' or 'categories' * @param bool $regenerate * @return bool */ protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products', $regenerate = true) { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); switch ($entity) { default: case 'products': $image_obj = new Image($id_image); $path = $image_obj->getPathForCreation(); break; case 'categories': $path = _PS_CAT_IMG_DIR_ . (int) $id_entity; break; case 'manufacturers': $path = _PS_MANU_IMG_DIR_ . (int) $id_entity; break; case 'suppliers': $path = _PS_SUPP_IMG_DIR_ . (int) $id_entity; break; } $url = urldecode(trim($url)); $parced_url = parse_url($url); if (isset($parced_url['path'])) { $uri = ltrim($parced_url['path'], '/'); $parts = explode('/', $uri); foreach ($parts as &$part) { $part = rawurlencode($part); } unset($part); $parced_url['path'] = '/' . implode('/', $parts); } if (isset($parced_url['query'])) { $query_parts = array(); parse_str($parced_url['query'], $query_parts); $parced_url['query'] = http_build_query($query_parts); } if (!function_exists('http_build_url')) { require_once _PS_TOOL_DIR_ . 'http_build_url/http_build_url.php'; } $url = http_build_url('', $parced_url); $orig_tmpfile = $tmpfile; if (Tools::copy($url, $tmpfile)) { // Evaluate the memory required to resize the image: if it's too much, you can't resize it. if (!ImageManager::checkImageMemoryLimit($tmpfile)) { @unlink($tmpfile); return false; } $tgt_width = $tgt_height = 0; $src_width = $src_height = 0; $error = 0; ImageManager::resize($tmpfile, $path . '.jpg', null, null, 'jpg', false, $error, $tgt_width, $tgt_height, 5, $src_width, $src_height); $images_types = ImageType::getImagesTypes($entity, true); if ($regenerate) { $previous_path = null; $path_infos = array(); $path_infos[] = array($tgt_width, $tgt_height, $path . '.jpg'); foreach ($images_types as $image_type) { $tmpfile = self::get_best_path($image_type['width'], $image_type['height'], $path_infos); if (ImageManager::resize($tmpfile, $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height'], 'jpg', false, $error, $tgt_width, $tgt_height, 5, $src_width, $src_height)) { // the last image should not be added in the candidate list if it's bigger than the original image if ($tgt_width <= $src_width && $tgt_height <= $src_height) { $path_infos[] = array($tgt_width, $tgt_height, $path . '-' . stripslashes($image_type['name']) . '.jpg'); } if ($entity == 'products') { if (is_file(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $id_entity . '.jpg')) { unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $id_entity . '.jpg'); } if (is_file(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $id_entity . '_' . (int) Context::getContext()->shop->id . '.jpg')) { unlink(_PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $id_entity . '_' . (int) Context::getContext()->shop->id . '.jpg'); } } } if (in_array($image_type['id_image_type'], $watermark_types)) { Hook::exec('actionWatermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } } } else { @unlink($orig_tmpfile); return false; } unlink($orig_tmpfile); return true; }
protected function productImportOne($info, $default_language_id, $id_lang, $force_ids, $regenerate, $shop_is_feature_active, $shop_ids, $match_ref, &$accessories, $validateOnly = false) { if ($force_ids && isset($info['id']) && (int) $info['id']) { $product = new Product((int) $info['id']); } elseif ($match_ref && array_key_exists('reference', $info)) { $datas = Db::getInstance()->getRow(' SELECT p.`id_product` FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE p.`reference` = "' . pSQL($info['reference']) . '" ', false); if (isset($datas['id_product']) && $datas['id_product']) { $product = new Product((int) $datas['id_product']); } else { $product = new Product(); } } elseif (array_key_exists('id', $info) && (int) $info['id'] && Product::existsInDatabase((int) $info['id'], 'product')) { $product = new Product((int) $info['id']); } else { $product = new Product(); } $update_advanced_stock_management_value = false; if (isset($product->id) && $product->id && Product::existsInDatabase((int) $product->id, 'product')) { $product->loadStockData(); $update_advanced_stock_management_value = true; $category_data = Product::getProductCategories((int) $product->id); if (is_array($category_data)) { foreach ($category_data as $tmp) { if (!isset($product->category) || !$product->category || is_array($product->category)) { $product->category[] = $tmp; } } } } AdminImportController::setEntityDefaultValues($product); AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product); if (!$shop_is_feature_active) { $product->shop = (int) Configuration::get('PS_SHOP_DEFAULT'); } elseif (!isset($product->shop) || empty($product->shop)) { $product->shop = implode($this->multiple_value_separator, Shop::getContextListShopID()); } if (!$shop_is_feature_active) { $product->id_shop_default = (int) Configuration::get('PS_SHOP_DEFAULT'); } else { $product->id_shop_default = (int) Context::getContext()->shop->id; } // link product to shops $product->id_shop_list = array(); foreach (explode($this->multiple_value_separator, $product->shop) as $shop) { if (!empty($shop) && !is_numeric($shop)) { $product->id_shop_list[] = Shop::getIdByName($shop); } elseif (!empty($shop)) { $product->id_shop_list[] = $shop; } } if ((int) $product->id_tax_rules_group != 0) { if (Validate::isLoadedObject(new TaxRulesGroup($product->id_tax_rules_group))) { $address = $this->context->shop->getAddress(); $tax_manager = TaxManagerFactory::getManager($address, $product->id_tax_rules_group); $product_tax_calculator = $tax_manager->getTaxCalculator(); $product->tax_rate = $product_tax_calculator->getTotalRate(); } else { $this->addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, $this->trans('Unknown tax rule group ID. You need to create a group with this ID first.', array(), 'Admin.Parameters.Notification')); } } if (isset($product->manufacturer) && is_numeric($product->manufacturer) && Manufacturer::manufacturerExists((int) $product->manufacturer)) { $product->id_manufacturer = (int) $product->manufacturer; } elseif (isset($product->manufacturer) && is_string($product->manufacturer) && !empty($product->manufacturer)) { if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) { $product->id_manufacturer = (int) $manufacturer; } else { $manufacturer = new Manufacturer(); $manufacturer->name = $product->manufacturer; $manufacturer->active = true; if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $manufacturer->add()) { $product->id_manufacturer = (int) $manufacturer->id; $manufacturer->associateTo($product->id_shop_list); } else { if (!$validateOnly) { $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $manufacturer->name, isset($manufacturer->id) && !empty($manufacturer->id) ? $manufacturer->id : 'null'); } if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } } } if (isset($product->supplier) && is_numeric($product->supplier) && Supplier::supplierExists((int) $product->supplier)) { $product->id_supplier = (int) $product->supplier; } elseif (isset($product->supplier) && is_string($product->supplier) && !empty($product->supplier)) { if ($supplier = Supplier::getIdByName($product->supplier)) { $product->id_supplier = (int) $supplier; } else { $supplier = new Supplier(); $supplier->name = $product->supplier; $supplier->active = true; if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $supplier->add()) { $product->id_supplier = (int) $supplier->id; $supplier->associateTo($product->id_shop_list); } else { if (!$validateOnly) { $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $supplier->name, isset($supplier->id) && !empty($supplier->id) ? $supplier->id : 'null'); } if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } } } if (isset($product->price_tex) && !isset($product->price_tin)) { $product->price = $product->price_tex; } elseif (isset($product->price_tin) && !isset($product->price_tex)) { $product->price = $product->price_tin; // If a tax is already included in price, withdraw it from price if ($product->tax_rate) { $product->price = (double) number_format($product->price / (1 + $product->tax_rate / 100), 6, '.', ''); } } elseif (isset($product->price_tin) && isset($product->price_tex)) { $product->price = $product->price_tex; } if (!Configuration::get('PS_USE_ECOTAX')) { $product->ecotax = 0; } if (isset($product->category) && is_array($product->category) && count($product->category)) { $product->id_category = array(); // Reset default values array foreach ($product->category as $value) { if (is_numeric($value)) { if (Category::categoryExists((int) $value)) { $product->id_category[] = (int) $value; } else { $category_to_create = new Category(); $category_to_create->id = (int) $value; $category_to_create->name = AdminImportController::createMultiLangField($value); $category_to_create->active = 1; $category_to_create->id_parent = Configuration::get('PS_HOME_CATEGORY'); // Default parent is home for unknown category to create $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]); $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite); if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $category_to_create->add()) { $product->id_category[] = (int) $category_to_create->id; } else { if (!$validateOnly) { $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $category_to_create->name[$default_language_id], isset($category_to_create->id) && !empty($category_to_create->id) ? $category_to_create->id : 'null'); } if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } } } } elseif (!$validateOnly && is_string($value) && !empty($value)) { $category = Category::searchByPath($default_language_id, trim($value), $this, 'productImportCreateCat'); if ($category['id_category']) { $product->id_category[] = (int) $category['id_category']; } else { $this->errors[] = sprintf($this->trans('%1$s cannot be saved', array(), 'Admin.Parameters.Notification'), trim($value)); } } } $product->id_category = array_values(array_unique($product->id_category)); // Will update default category if category column is not ignored AND if there is categories that are set in the import file row. if (isset($product->id_category[0])) { $product->id_category_default = (int) $product->id_category[0]; } else { $defaultProductShop = new Shop($product->id_shop_default); $product->id_category_default = Category::getRootCategory(null, Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null)->id; } } // Will update default category if there is none set here. Home if no category at all. if (!isset($product->id_category_default) || !$product->id_category_default) { // this if will avoid ereasing default category if category column is not present in the CSV file (or ignored) if (isset($product->id_category[0])) { $product->id_category_default = (int) $product->id_category[0]; } else { $defaultProductShop = new Shop($product->id_shop_default); $product->id_category_default = Category::getRootCategory(null, Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null)->id; } } $link_rewrite = is_array($product->link_rewrite) && isset($product->link_rewrite[$id_lang]) ? trim($product->link_rewrite[$id_lang]) : ''; $valid_link = Validate::isLinkRewrite($link_rewrite); if (isset($product->link_rewrite[$id_lang]) && empty($product->link_rewrite[$id_lang]) || !$valid_link) { $link_rewrite = Tools::link_rewrite($product->name[$id_lang]); if ($link_rewrite == '') { $link_rewrite = 'friendly-url-autogeneration-failed'; } } if (!$valid_link) { $this->informations[] = sprintf($this->trans('Rewrite link for %1$s (ID %2$s): re-written as %3$s.', array(), 'Admin.Parameters.Notification'), $product->name[$id_lang], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null', $link_rewrite); } if (!$valid_link || !($match_ref || $force_ids) || !(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) { $product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite); } // replace the value of separator by coma if ($this->multiple_value_separator != ',') { if (is_array($product->meta_keywords)) { foreach ($product->meta_keywords as &$meta_keyword) { if (!empty($meta_keyword)) { $meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword); } } } } // Convert comma into dot for all floating values foreach (Product::$definition['fields'] as $key => $array) { if ($array['type'] == Product::TYPE_FLOAT) { $product->{$key} = str_replace(',', '.', $product->{$key}); } } // Indexation is already 0 if it's a new product, but not if it's an update $product->indexed = 0; $productExistsInDatabase = false; if ($product->id && Product::existsInDatabase((int) $product->id, 'product')) { $productExistsInDatabase = true; } if ($match_ref && $product->reference && $product->existsRefInDatabase($product->reference) || $productExistsInDatabase) { $product->date_upd = date('Y-m-d H:i:s'); } $res = false; $field_error = $product->validateFields(UNFRIENDLY_ERROR, true); $lang_field_error = $product->validateFieldsLang(UNFRIENDLY_ERROR, true); if ($field_error === true && $lang_field_error === true) { // check quantity if ($product->quantity == null) { $product->quantity = 0; } // If match ref is specified && ref product && ref product already in base, trying to update if ($match_ref && $product->reference && $product->existsRefInDatabase($product->reference)) { $datas = Db::getInstance()->getRow(' SELECT product_shop.`date_add`, p.`id_product` FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE p.`reference` = "' . pSQL($product->reference) . '" ', false); $product->id = (int) $datas['id_product']; $product->date_add = pSQL($datas['date_add']); $res = $validateOnly || $product->update(); } elseif ($productExistsInDatabase) { $datas = Db::getInstance()->getRow(' SELECT product_shop.`date_add` FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE p.`id_product` = ' . (int) $product->id, false); $product->date_add = pSQL($datas['date_add']); $res = $validateOnly || $product->update(); } // If no id_product or update failed $product->force_id = (bool) $force_ids; if (!$res) { if (isset($product->date_add) && $product->date_add != '') { $res = $validateOnly || $product->add(false); } else { $res = $validateOnly || $product->add(); } } if (!$validateOnly) { if ($product->getType() == Product::PTYPE_VIRTUAL) { StockAvailable::setProductOutOfStock((int) $product->id, 1); } else { StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock); } if ($product_download_id = ProductDownload::getIdFromIdProduct((int) $product->id)) { $product_download = new ProductDownload($product_download_id); $product_download->delete(true); } if ($product->getType() == Product::PTYPE_VIRTUAL) { $product_download = new ProductDownload(); $product_download->filename = ProductDownload::getNewFilename(); Tools::copy($info['file_url'], _PS_DOWNLOAD_DIR_ . $product_download->filename); $product_download->id_product = (int) $product->id; $product_download->nb_downloadable = (int) $info['nb_downloadable']; $product_download->date_expiration = $info['date_expiration']; $product_download->nb_days_accessible = (int) $info['nb_days_accessible']; $product_download->display_filename = basename($info['file_url']); $product_download->add(); } } } $shops = array(); $product_shop = explode($this->multiple_value_separator, $product->shop); foreach ($product_shop as $shop) { if (empty($shop)) { continue; } $shop = trim($shop); if (!empty($shop) && !is_numeric($shop)) { $shop = Shop::getIdByName($shop); } if (in_array($shop, $shop_ids)) { $shops[] = $shop; } else { $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid')); } } if (empty($shops)) { $shops = Shop::getContextListShopID(); } // If both failed, mysql error if (!$res) { $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID'); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError(); } else { // Product supplier if (!$validateOnly && isset($product->id) && $product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) { $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier); if ($id_product_supplier) { $product_supplier = new ProductSupplier($id_product_supplier); } else { $product_supplier = new ProductSupplier(); } $product_supplier->id_product = (int) $product->id; $product_supplier->id_product_attribute = 0; $product_supplier->id_supplier = (int) $product->id_supplier; $product_supplier->product_supplier_price_te = $product->wholesale_price; $product_supplier->product_supplier_reference = $product->supplier_reference; $product_supplier->save(); } // SpecificPrice (only the basic reduction feature is supported by the import) if (!$shop_is_feature_active) { $info['shop'] = 1; } elseif (!isset($info['shop']) || empty($info['shop'])) { $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID()); } // Get shops for each attributes $info['shop'] = explode($this->multiple_value_separator, $info['shop']); $id_shop_list = array(); foreach ($info['shop'] as $shop) { if (!empty($shop) && !is_numeric($shop)) { $id_shop_list[] = (int) Shop::getIdByName($shop); } elseif (!empty($shop)) { $id_shop_list[] = $shop; } } if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) { foreach ($id_shop_list as $id_shop) { $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0); if (is_array($specific_price) && isset($specific_price['id_specific_price'])) { $specific_price = new SpecificPrice((int) $specific_price['id_specific_price']); } else { $specific_price = new SpecificPrice(); } $specific_price->id_product = (int) $product->id; $specific_price->id_specific_price_rule = 0; $specific_price->id_shop = $id_shop; $specific_price->id_currency = 0; $specific_price->id_country = 0; $specific_price->id_group = 0; $specific_price->price = -1; $specific_price->id_customer = 0; $specific_price->from_quantity = 1; $specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100; $specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage'; $specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00'; $specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00'; if (!$validateOnly && !$specific_price->save()) { $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid')); } } } if (!$validateOnly && isset($product->tags) && !empty($product->tags)) { if (isset($product->id) && $product->id) { $tags = Tag::getProductTags($product->id); if (is_array($tags) && count($tags)) { if (!empty($product->tags)) { $product->tags = explode($this->multiple_value_separator, $product->tags); } if (is_array($product->tags) && count($product->tags)) { foreach ($product->tags as $key => $tag) { if (!empty($tag)) { $product->tags[$key] = trim($tag); } } $tags[$id_lang] = $product->tags; $product->tags = $tags; } } } // Delete tags for this id product, for no duplicating error Tag::deleteTagsForProduct($product->id); if (!is_array($product->tags) && !empty($product->tags)) { $product->tags = AdminImportController::createMultiLangField($product->tags); foreach ($product->tags as $key => $tags) { $is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator); if (!$is_tag_added) { $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid')); break; } } } else { foreach ($product->tags as $key => $tags) { $str = ''; foreach ($tags as $one_tag) { $str .= $one_tag . $this->multiple_value_separator; } $str = rtrim($str, $this->multiple_value_separator); $is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator); if (!$is_tag_added) { $this->addProductWarning(Tools::safeOutput($info['name']), (int) $product->id, 'Invalid tag(s) (' . $str . ')'); break; } } } } //delete existing images if "delete_existing_images" is set to 1 if (!$validateOnly && isset($product->delete_existing_images)) { if ((bool) $product->delete_existing_images) { $product->deleteImages(); } } if (!$validateOnly && isset($product->image) && is_array($product->image) && count($product->image)) { $product_has_images = (bool) Image::getImages($this->context->language->id, (int) $product->id); foreach ($product->image as $key => $url) { $url = trim($url); $error = false; if (!empty($url)) { $url = str_replace(' ', '%20', $url); $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = !$key && !$product_has_images ? true : false; $alt = $product->image_alt[$key]; if (strlen($alt) > 0) { $image->legend = self::createMultiLangField($alt); } // file_exists doesn't work with HTTP protocol if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) { // associate image to selected shops $image->associateTo($shops); if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !$regenerate)) { $image->delete(); $this->warnings[] = sprintf($this->trans('Error copying image: %s', array(), 'Admin.Parameters.Notification'), $url); } } else { $error = true; } } else { $error = true; } if ($error) { $this->warnings[] = sprintf($this->trans('Product #%1$d: the picture (%2$s) cannot be saved.', array(), 'Admin.Parameters.Notification'), $image->id_product, $url); } } } if (!$validateOnly && isset($product->id_category) && is_array($product->id_category)) { $product->updateCategories(array_map('intval', $product->id_category)); } $product->checkDefaultAttributes(); if (!$validateOnly && !$product->cache_default_attribute) { Product::updateDefaultAttribute($product->id); } // Features import $features = get_object_vars($product); if (!$validateOnly && isset($features['features']) && !empty($features['features'])) { foreach (explode($this->multiple_value_separator, $features['features']) as $single_feature) { if (empty($single_feature)) { continue; } $tab_feature = explode(':', $single_feature); $feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : ''; $feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : ''; $position = isset($tab_feature[2]) ? (int) $tab_feature[2] - 1 : false; $custom = isset($tab_feature[3]) ? (int) $tab_feature[3] : false; if (!empty($feature_name) && !empty($feature_value)) { $id_feature = (int) Feature::addFeatureImport($feature_name, $position); $id_product = null; if ($force_ids || $match_ref) { $id_product = (int) $product->id; } $id_feature_value = (int) FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom); Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value); } } } // clean feature positions to avoid conflict Feature::cleanPositions(); // set advanced stock managment if (!$validateOnly && isset($product->advanced_stock_management)) { if ($product->advanced_stock_management != 1 && $product->advanced_stock_management != 0) { $this->warnings[] = sprintf($this->trans('Advanced stock management has incorrect value. Not set for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]); } elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management == 1) { $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot enable on product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]); } elseif ($update_advanced_stock_management_value) { $product->setAdvancedStockManagement($product->advanced_stock_management); } // automaticly disable depends on stock, if a_s_m set to disabled if (StockAvailable::dependsOnStock($product->id) == 1 && $product->advanced_stock_management == 0) { StockAvailable::setProductDependsOnStock($product->id, 0); } } // Check if warehouse exists if (isset($product->warehouse) && $product->warehouse) { if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, warehouse not set on product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]); } elseif (!$validateOnly) { if (Warehouse::exists($product->warehouse)) { // Get already associated warehouses $associated_warehouses_collection = WarehouseProductLocation::getCollection($product->id); // Delete any entry in warehouse for this product foreach ($associated_warehouses_collection as $awc) { $awc->delete(); } $warehouse_location_entity = new WarehouseProductLocation(); $warehouse_location_entity->id_product = $product->id; $warehouse_location_entity->id_product_attribute = 0; $warehouse_location_entity->id_warehouse = $product->warehouse; if (WarehouseProductLocation::getProductLocation($product->id, 0, $product->warehouse) !== false) { $warehouse_location_entity->update(); } else { $warehouse_location_entity->save(); } StockAvailable::synchronize($product->id); } else { $this->warnings[] = sprintf($this->trans('Warehouse did not exist, cannot set on product %1$s.', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]); } } } // stock available if (isset($product->depends_on_stock)) { if ($product->depends_on_stock != 0 && $product->depends_on_stock != 1) { $this->warnings[] = sprintf($this->trans('Incorrect value for "Depends on stock" for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]); } elseif ((!$product->advanced_stock_management || $product->advanced_stock_management == 0) && $product->depends_on_stock == 1) { $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot set "Depends on stock" for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]); } elseif (!$validateOnly) { StockAvailable::setProductDependsOnStock($product->id, $product->depends_on_stock); } // This code allows us to set qty and disable depends on stock if (!$validateOnly && isset($product->quantity) && (int) $product->quantity) { // if depends on stock and quantity, add quantity to stock if ($product->depends_on_stock == 1) { $stock_manager = StockManagerFactory::getManager(); $price = str_replace(',', '.', $product->wholesale_price); if ($price == 0) { $price = 1.0E-6; } $price = round(floatval($price), 6); $warehouse = new Warehouse($product->warehouse); if ($stock_manager->addProduct((int) $product->id, 0, $warehouse, (int) $product->quantity, 1, $price, true)) { StockAvailable::synchronize((int) $product->id); } } else { if ($shop_is_feature_active) { foreach ($shops as $shop) { StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $shop); } } else { StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $this->context->shop->id); } } } } elseif (!$validateOnly) { // if not depends_on_stock set, use normal qty if ($shop_is_feature_active) { foreach ($shops as $shop) { StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $shop); } } else { StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $this->context->shop->id); } } // Accessories linkage if (isset($product->accessories) && !$validateOnly && is_array($product->accessories) && count($product->accessories)) { $accessories[$product->id] = $product->accessories; } } }
public static function copy($source, $destination, $stream_context = null) { $ypunjwq = "stream_context"; $clmkayb = "source"; if (version_compare(_PS_VERSION_, "1.5.5", ">=")) { return Tools::copy(${${"GLOBALS"}["cksorwgvlwyd"]}, ${${"GLOBALS"}["ceysvjdmrms"]}, ${${"GLOBALS"}["thsaegkzai"]}); } if (${${"GLOBALS"}["thsaegkzai"]} == null && preg_match("/^https?:\\/\\//", ${${"GLOBALS"}["cksorwgvlwyd"]})) { ${$ypunjwq} = @stream_context_create(array("http" => array("timeout" => 10))); } $eqekxhautj = "stream_context"; if (in_array(@ini_get("allow_url_fopen"), array("On", "on", "1")) || !preg_match("/^https?:\\/\\//", ${${"GLOBALS"}["cksorwgvlwyd"]})) { return @copy(${$clmkayb}, ${${"GLOBALS"}["ceysvjdmrms"]}, ${$eqekxhautj}); } elseif (function_exists("curl_init")) { $qvacjfx = "curl"; ${"GLOBALS"}["ikphwwrqeinv"] = "content"; ${"GLOBALS"}["dotwyyydait"] = "curl"; ${"GLOBALS"}["vsqilpqohv"] = "curl"; ${$qvacjfx} = curl_init(); $lujsdrvpu = "source"; curl_setopt(${${"GLOBALS"}["ebgeppdheuj"]}, CURLOPT_RETURNTRANSFER, 1); ${"GLOBALS"}["ipzmtbpoupmo"] = "curl"; curl_setopt(${${"GLOBALS"}["ebgeppdheuj"]}, CURLOPT_URL, ${$lujsdrvpu}); curl_setopt(${${"GLOBALS"}["vsqilpqohv"]}, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt(${${"GLOBALS"}["ipzmtbpoupmo"]}, CURLOPT_TIMEOUT, 10); curl_setopt(${${"GLOBALS"}["ebgeppdheuj"]}, CURLOPT_SSL_VERIFYPEER, 0); ${"GLOBALS"}["uujebuquq"] = "stream_context"; ${${"GLOBALS"}["qsnrljrynvp"]} = stream_context_get_options(${${"GLOBALS"}["uujebuquq"]}); ${${"GLOBALS"}["ikphwwrqeinv"]} = curl_exec(${${"GLOBALS"}["dotwyyydait"]}); curl_close(${${"GLOBALS"}["ebgeppdheuj"]}); return file_put_contents(${${"GLOBALS"}["ceysvjdmrms"]}, ${${"GLOBALS"}["xrduecnlhx"]}); } else { return false; } }
public static function copy($source, $destination, $stream_context = null) { $bhbrrao = "stream_context"; ${"GLOBALS"}["gncffogpncu"] = "source"; ${"GLOBALS"}["ycvofcxfiqo"] = "source"; if (version_compare(_PS_VERSION_, "1.5.5", ">=")) { return Tools::copy(${${"GLOBALS"}["gncffogpncu"]}, ${${"GLOBALS"}["pakcvjwghru"]}, ${${"GLOBALS"}["hqvnqhpl"]}); } if (${${"GLOBALS"}["hqvnqhpl"]} == null && preg_match("/^https?:\\/\\//", ${${"GLOBALS"}["hyycffh"]})) { ${$bhbrrao} = @stream_context_create(array("http" => array("timeout" => 10))); } ${"GLOBALS"}["ykojfrbbu"] = "stream_context"; if (in_array(@ini_get("allow_url_fopen"), array("On", "on", "1")) || !preg_match("/^https?:\\/\\//", ${${"GLOBALS"}["ycvofcxfiqo"]})) { return @copy(${${"GLOBALS"}["hyycffh"]}, ${${"GLOBALS"}["pakcvjwghru"]}, ${${"GLOBALS"}["ykojfrbbu"]}); } elseif (function_exists("curl_init")) { $zzdlkgupg = "curl"; ${"GLOBALS"}["blyywjnj"] = "stream_context"; $mtgbzijb = "curl"; $yeduzlfyz = "source"; ${"GLOBALS"}["tohkcjp"] = "opts"; ${$zzdlkgupg} = curl_init(); $fqithkgwleno = "curl"; $ofdfhta = "curl"; curl_setopt(${$mtgbzijb}, CURLOPT_RETURNTRANSFER, 1); ${"GLOBALS"}["qzhuhpmynn"] = "curl"; curl_setopt(${$ofdfhta}, CURLOPT_URL, ${$yeduzlfyz}); curl_setopt(${${"GLOBALS"}["qzhuhpmynn"]}, CURLOPT_CONNECTTIMEOUT, 5); $odphjdpmo = "content"; ${"GLOBALS"}["bllbibj"] = "content"; curl_setopt(${$fqithkgwleno}, CURLOPT_TIMEOUT, 10); curl_setopt(${${"GLOBALS"}["phoviclbnrp"]}, CURLOPT_SSL_VERIFYPEER, 0); ${${"GLOBALS"}["tohkcjp"]} = stream_context_get_options(${${"GLOBALS"}["blyywjnj"]}); ${${"GLOBALS"}["bllbibj"]} = curl_exec(${${"GLOBALS"}["phoviclbnrp"]}); curl_close(${${"GLOBALS"}["phoviclbnrp"]}); return file_put_contents(${${"GLOBALS"}["pakcvjwghru"]}, ${$odphjdpmo}); } else { return false; } }
/** * @param $state * @param $name * @return bool */ private function addOrderState($state, $name) { $orderState = new OrderState((int) Configuration::get($state)); if (!Validate::isLoadedObject($orderState)) { //Creating new order state $orderState->color = 'lightblue'; $orderState->unremovable = 1; $orderState->name = array(); foreach (Language::getLanguages() as $language) { $orderState->name[$language['id_lang']] = $name; } if (!$orderState->add()) { return false; } if (version_compare(_PS_VERSION_, '1.5.5.0', '>=')) { Tools::copy(dirname(__FILE__) . '/logo.gif', dirname(__FILE__) . '/../../img/os/' . (int) $orderState->id . '.gif'); } else { copy(dirname(__FILE__) . '/logo.gif', dirname(__FILE__) . '/../../img/os/' . (int) $orderState->id . '.gif'); } } return $this->configurations[$state] = $orderState->id; }