/** * Check then return multilingual fields for database interaction * * @return array Multilingual fields */ public function getTranslationsFieldsChild() { parent::validateFieldsLang(); $fieldsArray = array('title', 'url'); $fields = array(); $languages = Language::getLanguages(false); $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); foreach ($languages as $language) { $fields[$language['id_lang']]['id_lang'] = (int) $language['id_lang']; $fields[$language['id_lang']][self::$definition['primary']] = (int) $this->id; foreach ($fieldsArray as $field) { if (!Validate::isTableOrIdentifier($field)) { die(Tools::displayError()); } if (isset($this->{$field}[$language['id_lang']]) and !empty($this->{$field}[$language['id_lang']])) { $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']], true); } elseif (in_array($field, $this->fieldsRequiredLang)) { $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage], true); } else { $fields[$language['id_lang']][$field] = ''; } } } return $fields; }
public function postProcess() { parent::postProcess(); if (Tools::isSubmit('markAsReceived')) { $idOrder = (int) Tools::getValue('id_order'); $order = new Order($idOrder); if (Validate::isLoadedObject($order)) { if ($order->getCurrentState() == 15) { $new_history = new OrderHistory(); $new_history->id_order = (int) $order->id; $new_history->changeIdOrderState(16, $order); // 16: Ready for Production //var_dump($order,$new_history); $myfile = fopen(PS_PRODUCT_IMG_PATH . "/orders/" . $order->reference . ".txt", "w") or die("Unable to open file!"); $txt = "Order Confirmed\n Order Reference: " . $order->reference; fwrite($myfile, $txt); fclose($myfile); $new_history->addWithemail(true); } $this->context->smarty->assign('receipt_confirmation', true); } else { $this->_errors[] = Tools::displayError('Error: Invalid order number'); } } }
public function initContent() { $this->errors[] = Tools::displayError('Controller not found'); $tpl_vars['controller'] = Tools::getvalue('controllerUri', Tools::getvalue('controller')); $this->context->smarty->assign($tpl_vars); parent::initContent(); }
/** * For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated * * @param int $id_product * @param int $id_product_attribute Optional * @param int $id_shop Optional * @return int */ public function updateWs() { if ($this->depends_on_stock) { return WebserviceRequest::getInstance()->setError(500, Tools::displayError('You can\'t update stock available when it\'s depend on stock')); } return $this->update(); }
function upgrade_module_1_3_2_11($object) { $themes = Theme::getThemes(); $theme_meta_value = array(); foreach ($object->controllers as $controller) { $page = 'module-' . $object->name . '-' . $controller; $result = Db::getInstance()->getValue('SELECT * FROM ' . _DB_PREFIX_ . 'meta WHERE page="' . pSQL($page) . '"'); if ((int) $result > 0) { continue; } $meta = new Meta(); $meta->page = $page; $meta->configurable = 0; $meta->save(); if ((int) $meta->id > 0) { foreach ($themes as $theme) { $theme_meta_value[] = array('id_theme' => $theme->id, 'id_meta' => $meta->id, 'left_column' => (int) $theme->default_left_column, 'right_column' => (int) $theme->default_right_column); } } else { $object->_errors[] = sprintf(Tools::displayError('Unable to install controller: %s'), $controller); } } if (count($theme_meta_value) > 0) { return Db::getInstance()->insert('theme_meta', $theme_meta_value); } return true; }
public static function getPages($excludeFilled = false, $addPage = false) { $selectedPages = array(); if (!($files = scandir(_PS_ROOT_DIR_))) { die(Tools::displayError('Cannot scan base URI')); } // Exclude pages forbidden $exludePages = array('cart', 'order', 'my-account', 'history', 'addresses', 'address', 'identity', 'discount', 'authentication', 'search', 'get-file', 'order-slip', 'order-detail', 'order-follow', 'order-return', 'order-confirmation', 'pagination', 'pdf-invoice', 'pdf-order-return', 'pdf-order-slip', 'product-sort', 'statistics', 'zoom', 'images.inc', 'header', 'footer', 'init', 'category', 'product', 'cms'); foreach ($files as $file) { if (preg_match('/^[a-z0-9_.-]*\\.php$/i', $file) and !in_array(str_replace('.php', '', $file), $exludePages)) { $selectedPages[] = str_replace('.php', '', $file); } } // Exclude page already filled if ($excludeFilled) { $metas = self::getMetas(); foreach ($metas as $k => $meta) { if (in_array($meta['page'], $selectedPages)) { unset($selectedPages[array_search($meta['page'], $selectedPages)]); } } } // Add selected page if ($addPage) { $selectedPages[] = $addPage; sort($selectedPages); } return $selectedPages; }
public function process() { parent::process(); $multipleAddressesFormated = array(); $ordered_fields = array(); $customer = new Customer((int) self::$cookie->id_customer); if (!Validate::isLoadedObject($customer)) { die(Tools::displayError('Customer not found')); } // Retro Compatibility Theme < 1.4.1 self::$smarty->assign('addresses', $customer->getAddresses((int) self::$cookie->id_lang)); $customerAddressesDetailed = $customer->getAddresses((int) self::$cookie->id_lang); $total = 0; foreach ($customerAddressesDetailed as $addressDetailed) { $address = new Address($addressDetailed['id_address']); $multipleAddressesFormated[$total] = AddressFormat::getFormattedLayoutData($address); unset($address); ++$total; // Retro theme < 1.4.2 $ordered_fields = AddressFormat::getOrderedAddressFields($addressDetailed['id_country'], false, true); } // Retro theme 1.4.2 if ($key = array_search('Country:name', $ordered_fields)) { $ordered_fields[$key] = 'country'; } self::$smarty->assign('addresses_style', array('company' => 'address_company', 'vat_number' => 'address_company', 'firstname' => 'address_name', 'lastname' => 'address_name', 'address1' => 'address_address1', 'address2' => 'address_address2', 'city' => 'address_city', 'country' => 'address_country', 'phone' => 'address_phone', 'phone_mobile' => 'address_phone_mobile', 'alias' => 'address_title')); self::$smarty->assign(array('multipleAddresses' => $multipleAddressesFormated, 'ordered_fields' => $ordered_fields)); unset($customer); }
public function postProcess() { global $currentIndex; if (isset($_POST['submitLocalization' . $this->table])) { if ($this->tabAccess['edit'] === '1') { $this->_postConfig($this->_fieldsLocalization); } else { $this->_errors[] = Tools::displayError('You do not have permission to edit here.'); } } elseif (Tools::isSubmit('submitLocalizationPack')) { if (!($pack = @Tools::file_get_contents('http://www.prestashop.com/download/localization/' . Tools::getValue('iso_localization_pack') . '.xml')) and !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) { $this->_errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")'); } elseif (!($selection = Tools::getValue('selection'))) { $this->_errors[] = Tools::displayError('Please select at least one content item to import.'); } else { foreach ($selection as $selected) { if (!Validate::isLocalizationPackSelection($selected)) { $this->_errors[] = Tools::displayError('Invalid selection'); return; } } $localizationPack = new LocalizationPack(); if (!$localizationPack->loadLocalisationPack($pack, $selection)) { $this->_errors = array_merge($this->_errors, $localizationPack->getErrors()); } else { Tools::redirectAdmin($currentIndex . '&conf=23&token=' . $this->token); } } } parent::postProcess(); }
public function postProcess() { global $cookie; $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id); if (Tools::isSubmit('submitAdd' . $this->table)) { if ($id_category = intval(Tools::getValue('id_category'))) { if (!Category::checkBeforeMove($id_category, intval(Tools::getValue('id_parent')))) { $this->_errors[] = Tools::displayError('category cannot be moved here'); return false; } // Updating customer's group if ($this->tabAccess['edit'] !== '1') { $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.'); } else { $object = new $this->className($id_category); if (Validate::isLoadedObject($object)) { $object->updateGroup(Tools::getValue('groupBox')); } else { $this->_errors[] = Tools::displayError('an error occurred while updating object') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)'); } } } } parent::postProcess(); }
/** * @see FrontController::postProcess() */ public function postProcess() { $oplata = new Oplata(); if ($_POST['order_status'] == OplataCls::ORDER_DECLINED) { $this->errors[] = Tools::displayError('Order declined'); } $settings = array('merchant_id' => $oplata->getOption('merchant'), 'secret_key' => $oplata->getOption('secret_key')); $isPaymentValid = OplataCls::isPaymentValid($settings, $_POST); if ($isPaymentValid !== true) { $this->errors[] = Tools::displayError($isPaymentValid); } $cart = $this->context->cart; if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) { Tools::redirect('index.php?controller=order&step=1'); } $customer = new Customer($cart->id_customer); if (!Validate::isLoadedObject($customer)) { Tools::redirect('index.php?controller=order&step=1'); } if (empty($this->errors)) { list($orderId, ) = explode(OplataCls::ORDER_SEPARATOR, $_POST['order_id']); $history = new OrderHistory(); $history->id_order = $orderId; $history->changeIdOrderState((int) Configuration::get('PS_OS_PAYMENT'), $orderId); $history->addWithemail(true, array('order_name' => $orderId)); Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key); } }
/** * Initialize addresses controller * @see FrontController::init() */ public function init() { parent::init(); if (!Validate::isLoadedObject($this->context->customer)) { die(Tools::displayError('The customer could not be found.')); } }
public function postProcess() { ${"GLOBALS"}["blpimnned"] = "id_order_seller"; $dbodbxes = "id_order"; ${${"GLOBALS"}["qusrvgm"]} = (int) Tools::getValue("id_order"); if (!$this->context->customer->isLogged() && !Tools::getValue("secure_key")) { Tools::redirect("index.php?controller=authentication&back=my-account"); } ${"GLOBALS"}["tvasln"] = "id_order"; $jpdhpfqcj = "id_order"; if (!(int) Configuration::get("PS_INVOICE")) { die(Tools::displayError("Invoices are disabled in this shop.")); } if (isset(${${"GLOBALS"}["qusrvgm"]}) && Validate::isUnsignedId(${$dbodbxes})) { ${${"GLOBALS"}["ymjzko"]} = new Order(${$jpdhpfqcj}); } if (!isset(${${"GLOBALS"}["ymjzko"]}) || !Validate::isLoadedObject(${${"GLOBALS"}["ymjzko"]})) { die(Tools::displayError("Invoice not found")); } ${${"GLOBALS"}["vewtbt"]} = AgileSellerManager::getObjectOwnerID("order", ${${"GLOBALS"}["tvasln"]}); ${${"GLOBALS"}["sokafjqdei"]} = AgileSellerManager::getLinkedSellerID($this->context->customer->id); if (${${"GLOBALS"}["blpimnned"]} != ${${"GLOBALS"}["sokafjqdei"]}) { die(Tools::displayError("You do not have permission to see this invoice")); } if (Tools::isSubmit("secure_key") && $order->secure_key != Tools::getValue("secure_key")) { die(Tools::displayError("You do not have permission to see this invoice")); } if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number) { die(Tools::displayError("No invoice available")); } $this->order = ${${"GLOBALS"}["ymjzko"]}; }
public static function isItemsOrder($value) { $str_error = Tools::displayError('For the items'); foreach ($value as $key => $item) { $str_error .= ' ' . $key . ' '; $str_error .= isset($item['name']) ? $item['name'] . ' ' : ''; $str_error .= ' :'; if (isset($item['total_ht']) && !Validate::isFloat($item['total_ht'])) { throw new TwengaFieldsException($str_error . Tools::displayError('The total HT must be a float value.')); } if (isset($item['quantity']) && !Validate::isInt($item['quantity'])) { throw new TwengaFieldsException($str_error . Tools::displayError('The quantity must be a integer value.')); } if (isset($item['sku']) && !is_string($item['sku']) && strlen($item['sku']) > 40) { throw new TwengaFieldsException($str_error . Tools::displayError('The sku must be a string with length less than 40 chars.')); } if (isset($item['name']) && !is_string($item['name'])) { throw new TwengaFieldsException($str_error . Tools::displayError('The name must be a string with length less than 100 chars.')); } if (isset($item['category_name']) && !is_string($item['category_name'])) { throw new TwengaFieldsException($str_error . Tools::displayError('The category name must be a string with length less than 100 chars.')); } } return true; }
public function ajaxProcessSendMailTest() { /* PrestaShop demo mode */ if (_PS_MODE_DEMO_) { die(Tools::displayError('This functionality has been disabled.')); } /* PrestaShop demo mode */ if ($this->tabAccess['view'] === '1') { $smtpChecked = trim(Tools::getValue('mailMethod')) == 'smtp'; $smtpServer = Tools::getValue('smtpSrv'); $content = urldecode(Tools::getValue('testMsg')); $content = html_entity_decode($content); $subject = urldecode(Tools::getValue('testSubject')); $type = 'text/html'; $to = Tools::getValue('testEmail'); $from = Configuration::get('PS_SHOP_EMAIL'); $smtpLogin = Tools::getValue('smtpLogin'); $smtpPassword = Tools::getValue('smtpPassword'); $smtpPassword = !empty($smtpPassword) ? urldecode($smtpPassword) : Configuration::get('PS_MAIL_PASSWD'); $smtpPassword = str_replace(array('<', '>', '"', '&'), array('<', '>', '"', '&'), Tools::htmlentitiesUTF8($smtpPassword)); $smtpPort = Tools::getValue('smtpPort'); $smtpEncryption = Tools::getValue('smtpEnc'); $result = Mail::sendMailTest(Tools::htmlentitiesUTF8($smtpChecked), Tools::htmlentitiesUTF8($smtpServer), Tools::htmlentitiesUTF8($content), Tools::htmlentitiesUTF8($subject), Tools::htmlentitiesUTF8($type), Tools::htmlentitiesUTF8($to), Tools::htmlentitiesUTF8($from), Tools::htmlentitiesUTF8($smtpLogin), $smtpPassword, Tools::htmlentitiesUTF8($smtpPort), Tools::htmlentitiesUTF8($smtpEncryption)); die($result === true ? 'ok' : $result); } }
private function getSellerByEmail($email, $passwd) { if (!Validate::isEmail($email) or $passwd != NULL and !Validate::isPasswd($passwd)) { die(Tools::displayError()); } $sql = ' SELECT * FROM `' . _DB_PREFIX_ . 'employee` WHERE `active` = 1 AND `email` = \'' . pSQL($email) . '\' ' . ($passwd ? 'AND `passwd` = \'' . $passwd . '\'' : ''); $result = Db::getInstance()->getRow($sql); if (!$result) { return false; } $emp = new Employee(); $emp->id = $result['id_employee']; $emp->id_profile = $result['id_profile']; foreach ($result as $key => $value) { if (key_exists($key, $emp)) { $emp->{$key} = $value; } } return $emp; }
/** * Get all available glossaries * * @param integer $id_lang Language id * @param array $criteria Criterias for where clause * @param integer $start Start number * @param integer $limit Number of glossaries to return * @param string $order_by Field for ordering * @param string $order_way Way for ordering (ASC or DESC) * @param boolean $only_active Returns only active glossaries if TRUE * @param Context|null $context * * @return array list of glossaries */ public static function getGlossaries($id_lang, $criteria = array(), $start = null, $limit = null, $order_by = null, $order_way = null, $only_active = false, Context $context = null) { $where = ''; if (!$context) { $context = Context::getContext(); } if ($order_by !== null) { if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) { die(Tools::displayError()); } if ($order_by == 'id') { $order_by_prefix = 'l'; } else { $order_by_prefix = 'll'; } if (strpos($order_by, '.') > 0) { $order_by = explode('.', $order_by); $order_by_prefix = $order_by[0]; $order_by = $order_by[1]; } } if (isset($criteria['k'])) { $where .= " AND ll.name LIKE '" . pSQL($criteria['k']) . "%' "; } $sql = 'SELECT l.*, ll.* FROM `' . _DB_PREFIX_ . 'lexikotron` l LEFT JOIN `' . _DB_PREFIX_ . 'lexikotron_lang` ll ON (l.`id_lexikotron` = ll.`id_lexikotron`) WHERE ll.`id_lang` = ' . (int) $id_lang . ($only_active ? ' AND l.`active` = 1' : '') . ' ' . $where . ' ' . ($order_by != null ? 'ORDER BY ' . (isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way) : '') . ($limit > 0 ? ' LIMIT ' . (int) $start . ',' . (int) $limit : ''); $rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); return $rows; }
/** * For a given {id_product, id_product_attribute and id_shop}, gets the stock available id associated * * @param int $id_product * @param int $id_product_attribute Optional * @param int $id_shop Optional * @return int */ public function updateWs() { if ($this->depends_on_stock) { return WebserviceRequest::getInstance()->setError(500, Tools::displayError('You cannot update the available stock when it depends on stock.'), 133); } return $this->update(); }
public function process() { if ($id_supplier = Tools::getValue('id_supplier')) { $this->supplier = new Supplier((int) $id_supplier, self::$cookie->id_lang); if (Validate::isLoadedObject($this->supplier) and $this->supplier->active) { $nbProducts = $this->supplier->getProducts($id_supplier, NULL, NULL, NULL, $this->orderBy, $this->orderWay, true); $this->pagination((int) $nbProducts); self::$smarty->assign(array('nb_products' => $nbProducts, 'products' => $this->supplier->getProducts($id_supplier, (int) self::$cookie->id_lang, (int) $this->p, (int) $this->n, $this->orderBy, $this->orderWay), 'path' => $this->supplier->active ? Tools::safeOutput($this->supplier->name) : '', 'supplier' => $this->supplier)); } else { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); $this->errors[] = Tools::displayError('Supplier does not exist'); } } else { if (Configuration::get('PS_DISPLAY_SUPPLIERS')) { $data = call_user_func(array('Supplier', 'getSuppliers'), true, (int) self::$cookie->id_lang, true); $nbProducts = count($data); $this->pagination($nbProducts); $data = call_user_func(array('Supplier', 'getSuppliers'), true, (int) self::$cookie->id_lang, true, $this->p, $this->n); $imgDir = _PS_MANU_IMG_DIR_; foreach ($data as &$item) { $item['image'] = !file_exists($imgDir . '/' . $item['id_supplier'] . '-medium.jpg') ? Language::getIsoById((int) self::$cookie->id_lang) . '-default' : $item['id_supplier']; } self::$smarty->assign(array('pages_nb' => ceil($nbProducts / (int) $this->n), 'nbSuppliers' => $nbProducts, 'mediumSize' => Image::getSize('medium'), 'suppliers' => $data, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'))); } else { self::$smarty->assign('nbSuppliers', 0); } } }
public function validateOrder($cart, $id_module, $id_order_status) { global $cookie; if (!Validate::isLoadedObject($cart)) { die(Tools::displayError()); } $currency = new Currency((int) $cart->id_currency); $order = new Order(); $order->id_cart = (int) $cart->id; $order->id_user = (int) $cart->id_user; $order->id_currency = (int) $cart->id_currency; $order->id_address = (int) $cart->id_address; $order->id_carrier = (int) $cart->id_carrier; $order->id_order_status = (int) $id_order_status; $order->id_module = (int) $id_module; $order->discount = floatval($cart->discount); $order->product_total = floatval($cart->getProductTotal()); $order->shipping_total = floatval($cart->getShippingTotal()); $order->amount = floatval($cart->getOrderTotal()); $order->conversion_rate = floatval($currency->conversion_rate); $order->track_number = "null"; if ($order->add()) { unset($cookie->id_cart); $this->currentOrder = $order->id; if ($id_order_status == 2) { $products = $cart->getProducts(); foreach ($products as $row) { Product::updateOrders($row['id_product']); } } return true; } return false; }
function processOrderStep($params) { global $cart, $smarty, $errors, $isVirtualCart, $orderTotal; $cart->recyclable = (isset($_POST['recyclable']) and !empty($_POST['recyclable'])) ? 1 : 0; if (isset($_POST['gift']) and !empty($_POST['gift'])) { if (!Validate::isMessage($_POST['gift_message'])) { $errors[] = Tools::displayError('invalid gift message'); } else { $cart->gift = 1; $cart->gift_message = strip_tags($_POST['gift_message']); } } else { $cart->gift = 0; } $address = new Address(intval($cart->id_address_delivery)); if (!Validate::isLoadedObject($address)) { die(Tools::displayError()); } if (!($id_zone = Address::getZoneById($address->id))) { $errors[] = Tools::displayError('no zone match with your address'); } if (isset($_POST['id_carrier']) and Validate::isInt($_POST['id_carrier']) and sizeof(Carrier::checkCarrierZone(intval($_POST['id_carrier']), intval($id_zone)))) { $cart->id_carrier = intval($_POST['id_carrier']); } elseif (!$isVirtualCart) { $errors[] = Tools::displayError('invalid carrier or no carrier selected'); } Module::hookExec('extraCarrierDetailsProcess', array('carrier' => new Carrier($cart->id_carrier))); $cart->update(); }
function textRecord(Product $product, Cart $cart) { global $errors; if (!($fieldIds = $product->getCustomizationFieldIds())) { return false; } $authorizedTextFields = array(); foreach ($fieldIds as $fieldId) { if ($fieldId['type'] == _CUSTOMIZE_TEXTFIELD_) { $authorizedTextFields[intval($fieldId['id_customization_field'])] = 'textField' . intval($fieldId['id_customization_field']); } } $indexes = array_flip($authorizedTextFields); foreach ($_POST as $fieldName => $value) { if (in_array($fieldName, $authorizedTextFields) and !empty($value)) { if (!Validate::isMessage($value)) { $errors[] = Tools::displayError('Invalid message'); } else { $cart->addTextFieldToProduct(intval($product->id), $indexes[$fieldName], $value); } } elseif (in_array($fieldName, $authorizedTextFields) and empty($value)) { $cart->deleteTextFieldFromProduct(intval($product->id), $indexes[$fieldName]); } } }
public function postProcess() { global $currentIndex; $this->product = new Product(intval(Tools::getValue('id_product'))); if (isset($_POST['generate'])) { if (!is_array(Tools::getValue('options'))) { $this->_errors[] = Tools::displayError('You need to choose at least 1 attribute.'); } else { $tab = array_values($_POST['options']); if (sizeof($tab) and Validate::isLoadedObject($this->product)) { self::setAttributesImpacts($this->product->id, $tab); $this->combinations = array_values(self::createCombinations($tab)); $values = array_values(array_map(array($this, 'addAttribute'), $this->combinations)); $this->product->deleteProductAttributes(); $res = $this->product->addProductAttributeMultiple($values); $this->product->addAttributeCombinationMultiple($res, $this->combinations); } else { $this->_errors[] = Tools::displayError('Unable to initialize parameters, combinations is missing or object cannot be load.'); } } } elseif (isset($_POST['back'])) { Tools::redirectAdmin($currentIndex . '&id_product=' . intval(Tools::getValue('id_product')) . '&id_category=' . intval(Tools::getValue('id_category')) . '&addproduct' . '&tabs=2&token=' . Tools::getValue('token')); } parent::postProcess(); }
protected function validate(&$file) { $file['error'] = $this->checkUploadError($file['error']); if ($file['error']) { return false; } $post_max_size = Tools::convertBytes(ini_get('post_max_size')); $upload_max_filesize = Tools::convertBytes(ini_get('upload_max_filesize')); if ($post_max_size && $this->_getServerVars('CONTENT_LENGTH') > $post_max_size) { $file['error'] = Tools::displayError('The uploaded file exceeds the post_max_size directive in php.ini'); return false; } if ($upload_max_filesize && $this->_getServerVars('CONTENT_LENGTH') > $upload_max_filesize) { $file['error'] = Tools::displayError('The uploaded file exceeds the upload_max_filesize directive in php.ini'); return false; } if ($error = ImageManager::validateUpload($file, Tools::getMaxUploadSize($this->getMaxSize()), $this->getAcceptTypes())) { $file['error'] = $error; return false; } if ($file['size'] > $this->getMaxSize()) { $file['error'] = sprintf(Tools::displayError('File (size : %1s) is too big (max : %2s)'), $file['size'], $this->getMaxSize()); return false; } return true; }
public function postProcess() { if (isset($_GET['delete' . $this->table]) or Tools::getValue('submitDel' . $this->table)) { $this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.'); } else { if (Tools::getValue('submitAdd' . $this->table)) { $id_country = Tools::getValue('id_country'); $tmp_addr_format = new AddressFormat($id_country); $save_status = false; $is_new = is_null($tmp_addr_format->id_country); if ($is_new) { $tmp_addr_format = new AddressFormat(); $tmp_addr_format->id_country = $id_country; } $tmp_addr_format->format = Tools::getValue('address_layout'); if (strlen($tmp_addr_format->format) > 0) { if ($tmp_addr_format->checkFormatFields()) { $save_status = $is_new ? $tmp_addr_format->save() : $tmp_addr_format->update(); } else { $errorList = $tmp_addr_format->getErrorList(); foreach ($errorList as $numError => $error) { $this->_errors[] = $error; } } if (!$save_status) { $this->_errors[] = Tools::displayError('Invalid address layout' . Db::getInstance()->getMsgError()); } } unset($tmp_addr_format); } return parent::postProcess(); } }
public static function displayHelp($label, $iso_lang, $country, $ps_version) { $infos = HelpAccess::retrieveInfos($label, $iso_lang, $country, $ps_version); if (array_key_exists('image', $infos) && $infos['image'] != 'none') { echo ' <a class="help-button" href="#" onclick="showHelp(\'' . HelpAccess::URL . '\',\'' . $label . '\',\'' . $iso_lang . '\',\'' . $ps_version . '\',\'' . $infos['version'] . '\',\'' . $country . '\');" title="' . Tools::htmlentitiesUTF8($infos['tooltip']) . '"> <img id="help-' . $label . '" src="../img/admin/' . Tools::htmlentitiesUTF8($infos['image']) . '" alt="" class="middle" style="margin-top: -5px"/> ' . Tools::displayError('HELP') . ' </a> '; if (!empty($infos['tooltip'])) { echo ' <script type="text/javascript"> $(document).ready(function() { $("a.help-button").cluetip({ splitTitle: "|", cluetipClass: "help-button", showTitle: false, arrows: true, dropShadow: false, positionBy: "auto" }); }); </script>'; } } }
public function postProcess() { if (Tools::isSubmit('submitLocalizationPack')) { $version = str_replace('.', '', _PS_VERSION_); $version = substr($version, 0, 2); if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) { $pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml'); if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) { $this->errors[] = Tools::displayError('Cannot load the localization pack.'); } if (!($selection = Tools::getValue('selection'))) { $this->errors[] = Tools::displayError('Please select at least one item to import.'); } else { foreach ($selection as $selected) { if (!Validate::isLocalizationPackSelection($selected)) { $this->errors[] = Tools::displayError('Invalid selection'); return; } } $localization_pack = new LocalizationPack(); if (!$localization_pack->loadLocalisationPack($pack, $selection)) { $this->errors = array_merge($this->errors, $localization_pack->getErrors()); } else { Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token); } } } } // Remove the module list cache if the default country changed if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) { @unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST); } parent::postProcess(); }
public function postProcess() { if ($this->context->cart->id_customer == 0 || $this->context->cart->id_address_delivery == 0 || $this->context->cart->id_address_invoice == 0 || !$this->module->active) { Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1'); } // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process $authorized = false; foreach (Module::getPaymentModules() as $module) { if ($module['name'] == 'cashondelivery') { $authorized = true; break; } } if (!$authorized) { die(Tools::displayError('This payment method is not available.')); } $customer = new Customer($this->context->cart->id_customer); if (!Validate::isLoadedObject($customer)) { Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1'); } if (Tools::getValue('confirm')) { $customer = new Customer((int) $this->context->cart->id_customer); $extrafee = $this->module->getExtraFee($this->context->cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING)); $total = $this->context->cart->getOrderTotal(true, Cart::BOTH) + $extrafee; $this->module->validateOrder((int) $this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null, array(), null, false, $customer->secure_key); Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $this->context->cart->id . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $this->module->currentOrder); } }
public function postProcess() { global $currentIndex; if (isset($_POST['submitDatabase' . $this->table])) { if ($this->tabAccess['edit'] === '1') { foreach ($this->_fieldsDatabase as $field => $values) { if (isset($values['required']) and $values['required']) { if (($value = Tools::getValue($field)) == false and (string) $value != '0') { $this->_errors[] = Tools::displayError('field') . ' <b>' . $values['title'] . '</b> ' . Tools::displayError('is required'); } } } if (!sizeof($this->_errors)) { /* Datas are not saved in database but in config/settings.inc.php */ $settings = array(); foreach ($_POST as $k => $value) { if ($value) { $settings['_' . Tools::strtoupper($k) . '_'] = $value; } } rewriteSettingsFile(NULL, NULL, $settings); Tools::redirectAdmin($currentIndex . '&conf=6' . '&token=' . $this->token); } } else { $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.'); } } }
public function getTranslationsFieldsChild() { parent::validateFieldsLang(); $fieldsArray = array('meta_title', 'meta_description', 'meta_keywords', 'link_rewrite'); $fields = array(); $languages = Language::getLanguages(false); $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT'); foreach ($languages as $language) { $fields[$language['id_lang']]['id_lang'] = (int) $language['id_lang']; $fields[$language['id_lang']][$this->identifier] = (int) $this->id; $fields[$language['id_lang']]['content'] = isset($this->content[$language['id_lang']]) ? pSQL($this->content[$language['id_lang']], true) : ''; foreach ($fieldsArray as $field) { if (!Validate::isTableOrIdentifier($field)) { die(Tools::displayError()); } if (isset($this->{$field}[$language['id_lang']]) and !empty($this->{$field}[$language['id_lang']])) { $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$language['id_lang']]); } elseif (in_array($field, $this->fieldsRequiredLang)) { $fields[$language['id_lang']][$field] = pSQL($this->{$field}[$defaultLanguage]); } else { $fields[$language['id_lang']][$field] = ''; } } } return $fields; }
/** * @param array $aIdProductType * @param null $iIdLang * @param bool $bActive * @return mixed * @throws PrestaShopDatabaseException */ public static function getByIdProductTypes($aIdProductType = array(), $iIdLang = null, $bActive = true) { if (!Validate::isBool($bActive)) { die(Tools::displayError()); } if (empty($aIdProductType)) { return array(); } if (is_null($iIdLang)) { $iIdLang = (int) Context::getContext()->language->id; } $sSQL = ' SELECT * FROM `' . _DB_PREFIX_ . 'now_product_type` pt INNER JOIN `' . _DB_PREFIX_ . 'now_product_type_lang` ptl ON (pt.`id_now_product_type` = ptl.`id_now_product_type` AND ptl.`id_lang` = ' . (int) $iIdLang . ') WHERE 1 ' . ($bActive ? 'AND pt.`active` = 1' : '') . ' AND pt.`id_now_product_type` IN (' . implode(',', $aIdProductType) . ') '; $aResult = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sSQL); $aProductTypes = array(); foreach ($aResult as $aRow) { $aProductTypes[$aRow['id_now_product_type']] = $aRow; } return $aProductTypes; }