✨ Features: - Migrated ALL files to new S3 structure (Projects, Contacts, Accounts, HelpDesk, Invoice, etc.) - Added Nextcloud folder buttons to ALL modules - Fixed Nextcloud editor integration - WebSocket server for real-time updates - Redis Pub/Sub integration - File path manager for organized storage - Redis caching for performance (Functions.php) 📁 New Structure: Documents/Project/ProjectName_ID/file_docID.ext Documents/Contacts/FirstName_LastName_ID/file_docID.ext Documents/Accounts/AccountName_ID/file_docID.ext 🔧 Technical: - FilePathManager for standardized paths - S3StorageService integration - WebSocket server (Node.js + Docker) - Redis cache for getBasicModuleInfo() - Predis library for Redis connectivity 📝 Scripts: - Migration scripts for all modules - Test pages for WebSocket/SSE/Polling - Documentation (MIGRATION_*.md, REDIS_*.md) 🎯 Result: 15,000+ files migrated successfully!
117 lines
3.7 KiB
PHP
117 lines
3.7 KiB
PHP
<?php
|
||
/**
|
||
* ============================================
|
||
* SERVER.PHP - Обработка и отправка заявок
|
||
* ============================================
|
||
*
|
||
* БЕЗОПАСНОСТЬ: Credentials загружаются из .env
|
||
*
|
||
* Обновлено: 23.10.2025
|
||
*/
|
||
|
||
header('Access-Control-Allow-Origin: *');
|
||
|
||
ini_set('error_reporting', E_ALL);
|
||
ini_set('display_errors', 1);
|
||
ini_set('display_startup_errors', 1);
|
||
|
||
// Загрузка конфигурации из .env
|
||
require_once __DIR__ . '/config.php';
|
||
require 'vendor/autoload.php';
|
||
|
||
use PHPMailer\PHPMailer\PHPMailer;
|
||
use PHPMailer\PHPMailer\SMTP;
|
||
use PHPMailer\PHPMailer\Exception;
|
||
|
||
$mail = new PHPMailer(true);
|
||
$mail->CharSet = 'UTF-8';
|
||
$mail->isHTML(true);
|
||
|
||
try {
|
||
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
|
||
$mail->isSMTP();
|
||
$mail->Host = MAIL_HOST;
|
||
$mail->Port = MAIL_PORT;
|
||
$mail->SMTPAuth = true;
|
||
$mail->Username = MAIL_USERNAME;
|
||
$mail->Password = MAIL_PASSWORD;
|
||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
|
||
|
||
$mail->setFrom(MAIL_FROM_EMAIL, MAIL_FROM_NAME);
|
||
$mail->addAddress(MAIL_TO_1, 'Заявка с сайта clientright.ru');
|
||
$mail->addAddress(MAIL_TO_2, 'Заявка с сайта clientright.ru');
|
||
|
||
$mail->isHTML(true);
|
||
|
||
$upload_urls=$_POST['upload_urls'];
|
||
|
||
$files_names = $_POST['files_names'];
|
||
|
||
$files_array = [];
|
||
|
||
$appends=$_POST['appends'];
|
||
|
||
$lastname = str_replace(' ', '',$_POST['lastname']);
|
||
|
||
$new_post = array(
|
||
'__vtrftk' => CRM_SESSION_TOKEN,
|
||
'publicid' => CRM_PUBLIC_ID,
|
||
'urlencodeenable' => '1',
|
||
'name' => 'websiteticket',
|
||
);
|
||
|
||
$files_array=array();
|
||
if($upload_urls) {
|
||
foreach($upload_urls as $index => $upload_url) {
|
||
if($upload_url) {
|
||
$mail->addAttachment($upload_url);
|
||
$files_array = array_merge($files_array, array($files_names[$index] => new CURLFile(realpath($upload_url))));
|
||
$new_post[$files_names[$index]] = $upload_url;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
foreach($appends as $key => $itemjson){
|
||
$item=json_decode($itemjson);
|
||
$new_post[$item->crm_name] = $item->field_val;
|
||
}
|
||
|
||
$final_post = array_merge($new_post, $files_array);
|
||
|
||
$curl_connection = curl_init(CRM_WEBFORM_URL);
|
||
curl_setopt($curl_connection, CURLOPT_POST, 1);
|
||
curl_setopt($curl_connection, CURLOPT_HEADER, 0);
|
||
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
|
||
curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
|
||
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
|
||
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
|
||
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
|
||
curl_setopt($curl_connection, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data'));
|
||
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $final_post);
|
||
|
||
$result = curl_exec($curl_connection);
|
||
curl_close($curl_connection);
|
||
|
||
|
||
$mail->Subject = 'Заявкас с сайта clientright.ru ';
|
||
$mail->Body = 'Пользователь заполнил форму! <br>';
|
||
|
||
foreach($new_post as $key => $value) {
|
||
$mail->Body .= $key.' : '.$value.'<br>';
|
||
}
|
||
|
||
$mail->send();
|
||
|
||
} catch (Exception $e) {
|
||
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||
}
|
||
|
||
$files = glob('uploads/*');
|
||
foreach($files as $file){
|
||
if(is_file($file)) {
|
||
unlink($file);
|
||
}
|
||
}
|