first commit

This commit is contained in:
sujan
2024-08-06 18:06:00 +05:45
commit a2fa49071a
2745 changed files with 391199 additions and 0 deletions

View File

@ -0,0 +1,206 @@
<?php
namespace Opencart\Catalog\Controller\Information;
/**
* Class Contact
*
* @package Opencart\Catalog\Controller\Information
*/
class Contact extends \Opencart\System\Engine\Controller {
/**
* @return void
*/
public function index(): void {
$this->load->language('information/contact');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'language=' . $this->config->get('config_language'))
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/contact', 'language=' . $this->config->get('config_language'))
];
$data['send'] = $this->url->link('information/contact.send', 'language=' . $this->config->get('config_language'));
$this->load->model('tool/image');
if ($this->config->get('config_image')) {
$data['image'] = $this->model_tool_image->resize(html_entity_decode($this->config->get('config_image'), ENT_QUOTES, 'UTF-8'), $this->config->get('config_image_location_width'), $this->config->get('config_image_location_height'));
} else {
$data['image'] = false;
}
$data['store'] = $this->config->get('config_name');
$data['address'] = nl2br($this->config->get('config_address'));
$data['geocode'] = $this->config->get('config_geocode');
$data['geocode_hl'] = $this->config->get('config_language');
$data['telephone'] = $this->config->get('config_telephone');
$data['open'] = nl2br($this->config->get('config_open'));
$data['comment'] = nl2br($this->config->get('config_comment'));
$data['locations'] = [];
$this->load->model('localisation/location');
foreach ((array)$this->config->get('config_location') as $location_id) {
$location_info = $this->model_localisation_location->getLocation((int)$location_id);
if ($location_info) {
if (is_file(DIR_IMAGE . html_entity_decode($location_info['image'], ENT_QUOTES, 'UTF-8'))) {
$image = $this->model_tool_image->resize(html_entity_decode($location_info['image'], ENT_QUOTES, 'UTF-8'), $this->config->get('config_image_location_width'), $this->config->get('config_image_location_height'));
} else {
$image = '';
}
$data['locations'][] = [
'location_id' => $location_info['location_id'],
'name' => $location_info['name'],
'address' => nl2br($location_info['address']),
'geocode' => $location_info['geocode'],
'telephone' => $location_info['telephone'],
'image' => $image,
'open' => nl2br($location_info['open']),
'comment' => $location_info['comment']
];
}
}
$data['name'] = $this->customer->getFirstName();
$data['email'] = $this->customer->getEmail();
// Captcha
$this->load->model('setting/extension');
$extension_info = $this->model_setting_extension->getExtensionByCode('captcha', $this->config->get('config_captcha'));
if ($extension_info && $this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('contact', (array)$this->config->get('config_captcha_page'))) {
$data['captcha'] = $this->load->controller('extension/' . $extension_info['extension'] . '/captcha/' . $extension_info['code']);
} else {
$data['captcha'] = '';
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('information/contact', $data));
}
/**
* @return void
* @throws \Exception
*/
public function send(): void {
$this->load->language('information/contact');
$json = [];
$keys = [
'name',
'email',
'enquiry'
];
foreach ($keys as $key) {
if (!isset($this->request->post[$key])) {
$this->request->post[$key] = '';
}
}
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 32)) {
$json['error']['name'] = $this->language->get('error_name');
}
if (!filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
$json['error']['email'] = $this->language->get('error_email');
}
if ((oc_strlen($this->request->post['enquiry']) < 10) || (oc_strlen($this->request->post['enquiry']) > 3000)) {
$json['error']['enquiry'] = $this->language->get('error_enquiry');
}
// Captcha
$this->load->model('setting/extension');
$extension_info = $this->model_setting_extension->getExtensionByCode('captcha', $this->config->get('config_captcha'));
if ($extension_info && $this->config->get('captcha_' . $this->config->get('config_captcha') . '_status') && in_array('contact', (array)$this->config->get('config_captcha_page'))) {
$captcha = $this->load->controller('extension/' . $extension_info['extension'] . '/captcha/' . $extension_info['code'] . '.validate');
if ($captcha) {
$json['error']['captcha'] = $captcha;
}
}
if (!$json) {
if ($this->config->get('config_mail_engine')) {
$mail_option = [
'parameter' => $this->config->get('config_mail_parameter'),
'smtp_hostname' => $this->config->get('config_mail_smtp_hostname'),
'smtp_username' => $this->config->get('config_mail_smtp_username'),
'smtp_password' => html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'),
'smtp_port' => $this->config->get('config_mail_smtp_port'),
'smtp_timeout' => $this->config->get('config_mail_smtp_timeout')
];
$mail = new \Opencart\System\Library\Mail($this->config->get('config_mail_engine'), $mail_option);
$mail->setTo($this->config->get('config_email'));
// Less spam and fix bug when using SMTP like sendgrid.
$mail->setFrom($this->config->get('config_email'));
$mail->setReplyTo($this->request->post['email']);
$mail->setSender(html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8'));
$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
$mail->setText($this->request->post['enquiry']);
$mail->send();
}
$json['redirect'] = $this->url->link('information/contact.success', 'language=' . $this->config->get('config_language'), true);
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return void
*/
public function success(): void {
$this->load->language('information/contact');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'language=' . $this->config->get('config_language'))
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/contact', 'language=' . $this->config->get('config_language'))
];
$data['text_message'] = $this->language->get('text_message');
$data['continue'] = $this->url->link('common/home', 'language=' . $this->config->get('config_language'));
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
}
}

View File

@ -0,0 +1,206 @@
<?php
namespace Opencart\Catalog\Controller\Information;
/**
* Class Gdpr
*
* @package Opencart\Catalog\Controller\Information
*/
class Gdpr extends \Opencart\System\Engine\Controller {
/**
* @return object|\Opencart\System\Engine\Action|null
*/
public function index(): object|null {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_gdpr_id'));
if ($information_info) {
$this->load->language('information/gdpr');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'language=' . $this->config->get('config_language'))
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/gdpr', 'language=' . $this->config->get('config_language'))
];
$data['action'] = $this->url->link('information/gdpr.action', 'language=' . $this->config->get('config_language'));
$data['title'] = $information_info['title'];
$data['gdpr'] = $this->url->link('information/information', 'language=' . $this->config->get('config_language') . '&information_id=' . $information_info['information_id']);
$data['email'] = $this->customer->getEmail();
$data['store'] = $this->config->get('config_name');
$data['limit'] = $this->config->get('config_gdpr_limit');
$data['cancel'] = $this->url->link('account/account', 'language=' . $this->config->get('config_language'));
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('information/gdpr', $data));
return null;
} else {
return new \Opencart\System\Engine\Action('error/not_found');
}
}
/*
* Action Statuses
*
* EXPORT
*
* unverified = 0
* pending = 1
* complete = 3
*
* REMOVE
*
* unverified = 0
* pending = 1
* processing = 2
* delete = 3
*
* DENY
*
* unverified = 0
* pending = 1
* processing = 2
* denied = -1
*/
/**
* @return void
*/
public function action(): void {
$this->load->language('information/gdpr');
$json = [];
if (isset($this->request->post['email'])) {
$email = $this->request->post['email'];
} else {
$email = '';
}
if (isset($this->request->post['action'])) {
$action = $this->request->post['action'];
} else {
$action = '';
}
// Validate E-Mail
if ((oc_strlen($email) > 96) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
$json['error']['email'] = $this->language->get('error_email');
}
// Validate Action
$allowed = [
'export',
'remove'
];
if (!in_array($action, $allowed)) {
$json['error']['action'] = $this->language->get('error_action');
}
if (!$json) {
// Added additional check so people are not spamming requests
$status = true;
$this->load->model('account/gdpr');
$results = $this->model_account_gdpr->getGdprsByEmail($email);
foreach ($results as $result) {
if ($result['action'] == $action) {
$status = false;
break;
}
}
if ($status) {
$this->model_account_gdpr->addGdpr(oc_token(32), $email, $action);
}
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
/**
* @return object|\Opencart\System\Engine\Action|null
*/
public function success(): object|null {
if (isset($this->request->get['code'])) {
$code = (string)$this->request->get['code'];
} else {
$code = '';
}
$this->load->model('account/gdpr');
$gdpr_info = $this->model_account_gdpr->getGdprByCode($code);
if ($gdpr_info) {
$this->load->language('information/gdpr_success');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'language=' . $this->config->get('config_language'))
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_account'),
'href' => $this->url->link('information/gdpr', 'language=' . $this->config->get('config_language'))
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/gdpr.success', 'language=' . $this->config->get('config_language'))
];
if ($gdpr_info['status'] == 0) {
$this->model_account_gdpr->editStatus($gdpr_info['gdpr_id'], 1);
}
if ($gdpr_info['action'] == 'export') {
$data['text_message'] = $this->language->get('text_export');
} else {
$data['text_message'] = sprintf($this->language->get('text_remove'), $this->config->get('config_gdpr_limit'));
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('common/success', $data));
return null;
} else {
return new \Opencart\System\Engine\Action('error/not_found');
}
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace Opencart\Catalog\Controller\Information;
/**
* Class Information
*
* @package Opencart\Catalog\Controller\Information
*/
class Information extends \Opencart\System\Engine\Controller {
/**
* @return void
*/
public function index(): object|null {
$this->load->language('information/information');
if (isset($this->request->get['information_id'])) {
$information_id = (int)$this->request->get['information_id'];
} else {
$information_id = 0;
}
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($information_id);
if ($information_info) {
$this->document->setTitle($information_info['meta_title']);
$this->document->setDescription($information_info['meta_description']);
$this->document->setKeywords($information_info['meta_keyword']);
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'language=' . $this->config->get('config_language'))
];
$data['breadcrumbs'][] = [
'text' => $information_info['title'],
'href' => $this->url->link('information/information', 'language=' . $this->config->get('config_language') . '&information_id=' . $information_id)
];
$data['heading_title'] = $information_info['title'];
$data['description'] = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
$data['continue'] = $this->url->link('common/home', 'language=' . $this->config->get('config_language'));
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('information/information', $data));
} else {
return new \Opencart\System\Engine\Action('error/not_found');
}
return null;
}
/**
* @return void
*/
public function info(): void {
if (isset($this->request->get['information_id'])) {
$information_id = (int)$this->request->get['information_id'];
} else {
$information_id = 0;
}
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($information_id);
if ($information_info) {
$data['title'] = $information_info['title'];
$data['description'] = html_entity_decode($information_info['description'], ENT_QUOTES, 'UTF-8');
$this->response->addHeader('X-Robots-Tag: noindex');
$this->response->setOutput($this->load->view('information/information_info', $data));
}
}
}

View File

@ -0,0 +1,98 @@
<?php
namespace Opencart\Catalog\Controller\Information;
/**
* Class Sitemap
*
* @package Opencart\Catalog\Controller\Information
*/
class Sitemap extends \Opencart\System\Engine\Controller {
/**
* @return void
*/
public function index(): void {
$this->load->language('information/sitemap');
$this->document->setTitle($this->language->get('heading_title'));
$data['breadcrumbs'] = [];
$data['breadcrumbs'][] = [
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/home', 'language=' . $this->config->get('config_language'))
];
$data['breadcrumbs'][] = [
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('information/sitemap', 'language=' . $this->config->get('config_language'))
];
$this->load->model('catalog/category');
$data['categories'] = [];
$categories_1 = $this->model_catalog_category->getCategories(0);
foreach ($categories_1 as $category_1) {
$level_2_data = [];
$categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);
foreach ($categories_2 as $category_2) {
$level_3_data = [];
$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
foreach ($categories_3 as $category_3) {
$level_3_data[] = [
'name' => $category_3['name'],
'href' => $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $category_1['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id'])
];
}
$level_2_data[] = [
'name' => $category_2['name'],
'children' => $level_3_data,
'href' => $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $category_1['category_id'] . '_' . $category_2['category_id'])
];
}
$data['categories'][] = [
'name' => $category_1['name'],
'children' => $level_2_data,
'href' => $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $category_1['category_id'])
];
}
$data['special'] = $this->url->link('product/special', 'language=' . $this->config->get('config_language'));
$data['account'] = $this->url->link('account/account', 'language=' . $this->config->get('config_language'));
$data['edit'] = $this->url->link('account/edit', 'language=' . $this->config->get('config_language'));
$data['password'] = $this->url->link('account/password', 'language=' . $this->config->get('config_language'));
$data['address'] = $this->url->link('account/address', 'language=' . $this->config->get('config_language'));
$data['history'] = $this->url->link('account/order', 'language=' . $this->config->get('config_language'));
$data['download'] = $this->url->link('account/download', 'language=' . $this->config->get('config_language'));
$data['cart'] = $this->url->link('checkout/cart', 'language=' . $this->config->get('config_language'));
$data['checkout'] = $this->url->link('checkout/checkout', 'language=' . $this->config->get('config_language'));
$data['search'] = $this->url->link('product/search', 'language=' . $this->config->get('config_language'));
$data['contact'] = $this->url->link('information/contact', 'language=' . $this->config->get('config_language'));
$this->load->model('catalog/information');
$data['informations'] = [];
foreach ($this->model_catalog_information->getInformations() as $result) {
$data['informations'][] = [
'title' => $result['title'],
'href' => $this->url->link('information/information', 'language=' . $this->config->get('config_language') . '&information_id=' . $result['information_id'])
];
}
$data['column_left'] = $this->load->controller('common/column_left');
$data['column_right'] = $this->load->controller('common/column_right');
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');
$this->response->setOutput($this->load->view('information/sitemap', $data));
}
}