first commit

This commit is contained in:
Konstantin
2026-05-30 09:27:58 +03:00
commit de0344d218
2371 changed files with 661486 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
<?php
class ControllerToolCallback extends Controller {
public function index() {
$this->load->language('tool/upload');
$json = array();
$json['error'] = [];
if($this->request->post['product_id']){
$this->load->model('catalog/product');
$data['product_info'] = $this->model_catalog_product->getProduct($this->request->post['product_id']);
}
$data['config_name'] = $this->config->get('config_name');
$data['post'] = $this->request->post;
$message = $this->load->view('mail/request', $data);
$this->sendTG($message);
$mail = new Mail($this->config->get('config_mail_engine'));
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_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('Новая заявка');
$mail->setHtml($message);
$mail->send();
if($this->config->get('config_mail_alert_email')){
foreach(explode(",", $this->config->get('config_mail_alert_email')) as $email){
$mail->setTo(trim($email));
$mail->send();
}
}
$json['success'] = true;
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
private function sendTG($message){
$message = str_replace(['<div>','</div>'], '', $message);
$message = str_replace('<br>', PHP_EOL, $message);
$message = strip_tags($message, ['b','i','u','s','a','code','pre']);
$botToken = '6230708188:AAH5lLczb7oZ2xs8rTcRMchm1OxKZH7wLSo';
$chatId = -1003452493446;
$url = "https://api.telegram.org/bot{$botToken}/sendMessage";
// Параметры запроса
$params = [
'chat_id' => $chatId,
'text' => $message,
'parse_mode' => 'HTML',
];
// Инициализируем cURL
$ch = curl_init($url);
// Устанавливаем опции для cURL
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Выполняем запрос и получаем ответ
$response = curl_exec($ch);
// Закрываем cURL
curl_close($ch);
// Возвращаем ответ (можно использовать для отладки)
return $response;
}
}
+78
View File
@@ -0,0 +1,78 @@
<?php
class ControllerToolUpload extends Controller {
public function index() {
$this->load->language('tool/upload');
$json = array();
if (!empty($this->request->files['file']['name']) && is_file($this->request->files['file']['tmp_name'])) {
// Sanitize the filename
$filename = basename(preg_replace('/[^a-zA-Z0-9\.\-\s+]/', '', html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8')));
// Validate the filename length
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
$json['error'] = $this->language->get('error_filename');
}
// Allowed file extension types
$allowed = array();
$extension_allowed = preg_replace('~\r?\n~', "\n", $this->config->get('config_file_ext_allowed'));
$filetypes = explode("\n", $extension_allowed);
foreach ($filetypes as $filetype) {
$allowed[] = trim($filetype);
}
if (!in_array(strtolower(substr(strrchr($filename, '.'), 1)), $allowed)) {
$json['error'] = $this->language->get('error_filetype');
}
// Allowed file mime types
$allowed = array();
$mime_allowed = preg_replace('~\r?\n~', "\n", $this->config->get('config_file_mime_allowed'));
$filetypes = explode("\n", $mime_allowed);
foreach ($filetypes as $filetype) {
$allowed[] = trim($filetype);
}
if (!in_array($this->request->files['file']['type'], $allowed)) {
$json['error'] = $this->language->get('error_filetype');
}
// Check to see if any PHP files are trying to be uploaded
$content = file_get_contents($this->request->files['file']['tmp_name']);
if (preg_match('/\<\?php/i', $content)) {
$json['error'] = $this->language->get('error_filetype');
}
// Return any upload error
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 (!$json) {
$file = $filename . '.' . token(32);
move_uploaded_file($this->request->files['file']['tmp_name'], DIR_UPLOAD . $file);
// Hide the uploaded file name so people can not link to it directly.
$this->load->model('tool/upload');
$json['code'] = $this->model_tool_upload->addUpload($filename, $file);
$json['success'] = $this->language->get('text_upload');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}