duct_info['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')); } else { $this->data['thumb'] = ''; } $this->data['images'] = array(); $results = $this->model_catalog_product->getProductImages($this->request->get['product_id']); foreach ($results as $result) { $this->data['images'][] = array( 'popup' => $this->model_tool_image->resize($result['image'] , $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')), 'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_additional_width'), $this->config->get('config_image_additional_height')) ); } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))); } else { $this->data['price'] = false; } if ((float)$product_info['special']) { $this->data['special'] = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax'))); } else { $this->data['special'] = false; } if ($this->config->get('config_tax')) { $this->data['tax'] = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price']); } else { $this->data['tax'] = false; } $discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']); $this->data['discounts'] = array(); foreach ($discounts as $discount) { $this->data['discounts'][] = array( 'quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) ); } $this->data['options'] = array(); foreach ($this->model_catalog_product->getProductOptions($this->request->get['product_id']) as $option) { if ($option['type'] == 'select' || $option['type'] == 'radio' || $option['type'] == 'checkbox') { $option_value_data = array(); foreach ($option['option_value'] as $option_value) { if (!$option_value['subtract'] || ($option_value['quantity'] > 0)) { $option_value_data[] = array( 'product_option_value_id' => $option_value['product_option_value_id'], 'option_value_id' => $option_value['option_value_id'], 'name' => $option_value['name'], 'price' => (float)$option_value['price'] ? $this->currency->format($this->tax->calculate($option_value['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))) : false, 'price_prefix' => $option_value['price_prefix'] ); } } $this->data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'option_value' => $option_value_data, 'required' => $option['required'] ); } elseif ($option['type'] == 'text' || $option['type'] == 'textarea' || $option['type'] == 'file' || $option['type'] == 'date' || $option['type'] == 'datetime' || $option['type'] == 'time') { $this->data['options'][] = array( 'product_option_id' => $option['product_option_id'], 'option_id' => $option['option_id'], 'name' => $option['name'], 'type' => $option['type'], 'option_value' => $option['option_value'], 'required' => $option['required'] ); } } if ($product_info['minimum']) { $this->data['minimum'] = $product_info['minimum']; } else { $this->data['minimum'] = 1; } $this->data['review_status'] = $this->config->get('config_review_status'); $this->data['reviews'] = sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']); $this->data['rating'] = (int)$product_info['rating']; $this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8'); $this->data['attribute_groups'] = $this->model_catalog_product->getProductAttributes($this->request->get['product_id']); $this->data['products'] = array(); $results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')); } else { $image = false; } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = (int)$result['rating']; } else { $rating = false; } $this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']), ); } $this->data['tags'] = array(); $results = $this->model_catalog_product->getProductTags($this->request->get['product_id']); foreach ($results as $result) { $this->data['tags'][] = array( 'tag' => $result['tag'], 'href' => $this->url->link('product/search', 'filter_tag=' . $result['tag']) ); } $this->model_catalog_product->updateViewed($this->request->get['product_id']); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/product.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/product.tpl'; } else { $this->template = 'default/template/product/product.tpl'; } $this->children = array( 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header' ); $this->response->setOutput($this->render()); } else { $url = ''; if (isset($this->request->get['path'])) { $url .= '&path=' . $this->request->get['path']; } if (isset($this->request->get['manufacturer_id'])) { $url .= '&manufacturer_id=' . $this->request->get['manufacturer_id']; } if (isset($this->request->get['filter_name'])) { $url .= '&filter_name=' . $this->request->get['filter_name']; } if (isset($this->request->get['filter_tag'])) { $url .= '&filter_tag=' . $this->request->get['filter_tag']; } if (isset($this->request->get['filter_description'])) { $url .= '&filter_description=' . $this->request->get['filter_description']; } if (isset($this->request->get['filter_category_id'])) { $url .= '&filter_category_id=' . $this->request->get['filter_category_id']; } $this->data['breadcrumbs'][] = array( 'text' => $this->language->get('text_error'), 'href' => $this->url->link('product/product', $url . '&product_id=' . $product_id), 'separator' => $this->language->get('text_separator') ); $this->document->setTitle($this->language->get('text_error')); $this->data['heading_title'] = $this->language->get('text_error'); $this->data['text_error'] = $this->language->get('text_error'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['continue'] = $this->url->link('common/home'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) { $this->template = $this->config->get('config_template') . '/template/error/not_found.tpl'; } else { $this->template = 'default/template/error/not_found.tpl'; } $this->children = array( 'common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header' ); $this->response->setOutput($this->render()); } } public function review() { $this->language->load('product/product'); $this->load->model('catalog/review'); $this->data['text_no_reviews'] = $this->language->get('text_no_reviews'); if (isset($this->request->get['page'])) { $page = $this->request->get['page']; } else { $page = 1; } $this->data['reviews'] = array(); $review_total = $this->model_catalog_review->getTotalReviewsByProductId($this->request->get['product_id']); $results = $this->model_catalog_review->getReviewsByProductId($this->request->get['product_id'], ($page - 1) * 5, 5); foreach ($results as $result) { $this->data['reviews'][] = array( 'author' => $result['author'], 'text' => strip_tags($result['text']), 'rating' => (int)$result['rating'], 'reviews' => sprintf($this->language->get('text_reviews'), (int)$review_total), 'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])) ); } $pagination = new Pagination(); $pagination->total = $review_total; $pagination->page = $page; $pagination->limit = 5; $pagination->text = $this->language->get('text_pagination'); $pagination->url = $this->url->link('product/product/review', 'product_id=' . $this->request->get['product_id'] . '&page={page}'); $this->data['pagination'] = $pagination->render(); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/review.tpl')) { $this->template = $this->config->get('config_template') . '/template/product/review.tpl'; } else { $this->template = 'default/template/product/review.tpl'; } $this->response->setOutput($this->render()); } public function write() { $this->language->load('product/product'); $this->load->model('catalog/review'); $json = array(); if ((strlen(utf8_decode($this->request->post['name'])) < 3) || (strlen(utf8_decode($this->request->post['name'])) > 25)) { $json['error'] = $this->language->get('error_name'); } if ((strlen(utf8_decode($this->request->post['text'])) < 25) || (strlen(utf8_decode($this->request->post['text'])) > 1000)) { $json['error'] = $this->language->get('error_text'); } if (!$this->request->post['rating']) { $json['error'] = $this->language->get('error_rating'); } if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) { $json['error'] = $this->language->get('error_captcha'); } if (($this->request->server['REQUEST_METHOD'] == 'POST') && !isset($json['error'])) { $this->model_catalog_review->addReview($this->request->get['product_id'], $this->request->post); $json['success'] = $this->language->get('text_success'); // Text $text = $this->language->get('alert_product') . $this->url->link('product/product', 'product_id=' . $this->request->get['product_id']) . "\n\n"; $text .= $this->language->get('alert_reviewer') . $this->request->post['name'] . "\n\n"; $text .= $this->language->get('alert_rating') . $this->request->post['rating'] . "\n\n"; $text .= $this->language->get('alert_message') . "\n\n" . $this->request->post['text'] . "\n\n"; $text .= '------------------------------------' . "\n\n"; $text .= $this->language->get('alert_moderate'); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($this->config->get('config_email')); $mail->setFrom($this->config->get('config_email')); $mail->setSender($this->config->get('config_name')); $mail->setSubject($this->language->get('alert_subject')); $mail->setText(strip_tags(html_entity_decode($text, ENT_QUOTES, 'UTF-8'))); $mail->send(); } $this->load->library('json'); $this->response->setOutput(Json::encode($json)); } public function captcha() { $this->load->library('captcha'); $captcha = new Captcha(); $this->session->data['captcha'] = $captcha->getCode(); $captcha->showImage(); } public function upload() { $this->language->load('product/product'); $json = array(); if (isset($this->request->files['file']['name']) && $this->request->files['file']['name']) { if ((strlen(utf8_decode($this->request->files['file']['name'])) < 3) || (strlen(utf8_decode($this->request->files['file']['name'])) > 128)) { $json['error'] = $this->language->get('error_filename'); } $allowed = array(); $filetypes = explode(',', $this->config->get('config_upload_allowed')); foreach ($filetypes as $filetype) { $allowed[] = trim($filetype); } if (!in_array(substr(strrchr($this->request->files['file']['name'], '.'), 1), $allowed)) { $json['error'] = $this->language->get('error_filetype'); } if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) { $json['error'] = $this->language->get('error_upload_' . $this->request->files['file']['error']); } } else { $json['error'] = $this->language->get('error_upload'); } if (($this->request->server['REQUEST_METHOD'] == 'POST') && !isset($json['error'])) { if (is_uploaded_file($this->request->files['file']['tmp_name']) && file_exists($this->request->files['file']['tmp_name'])) { $file = basename($this->request->files['file']['name']) . '.' . md5(rand()); // Hide the uploaded file name sop people can not link to it directly. $this->load->library('encryption'); $encryption = new Encryption($this->config->get('config_encryption')); $json['file'] = $encryption->encrypt($file); move_uploaded_file($this->request->files['file']['tmp_name'], DIR_DOWNLOAD . $file); } $json['success'] = $this->language->get('text_upload'); } $this->load->library('json'); $this->response->setOutput(Json::encode($json)); } } ?>