120 lines
4.6 KiB
PHP
120 lines
4.6 KiB
PHP
|
|
<?php
|
|||
|
|
// Тест создания клиента через server_webservice2.php
|
|||
|
|
// Файл: test_createcontact.php
|
|||
|
|
|
|||
|
|
echo "<h2>🧪 ТЕСТ СОЗДАНИЯ КЛИЕНТА ЧЕРЕЗ SERVER_WEBSERVICE2.PHP</h2>";
|
|||
|
|
echo "<p><strong>Время:</strong> " . date('Y-m-d H:i:s') . "</p>";
|
|||
|
|
echo "<hr>";
|
|||
|
|
|
|||
|
|
// Формируем данные только для клиента
|
|||
|
|
$appends = [
|
|||
|
|
'{"ws_type":"client","ws_name":"firstname","field_val":"Тест"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"secondname","field_val":"Тестович"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"lastname","field_val":"Тестов"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"mobile","field_val":"999 999-99-99"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"email","field_val":"test@test.com"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"birthday","field_val":"1990-01-01"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"mailingstreet","field_val":"Тестовый адрес"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"inn","field_val":"123456789012"}',
|
|||
|
|
'{"ws_type":"client","ws_name":"code","field_val":"999"}'
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
// Данные для отправки
|
|||
|
|
$data = [
|
|||
|
|
'appends' => $appends,
|
|||
|
|
'lastname' => 'Тестов',
|
|||
|
|
'sub_dir' => session_id(),
|
|||
|
|
'upload_urls' => [],
|
|||
|
|
'upload_urls_real' => [],
|
|||
|
|
'files_names' => [],
|
|||
|
|
'docs_names' => [],
|
|||
|
|
'docs_ticket_files_ids' => [],
|
|||
|
|
'getservice' => ''
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
echo "<h3>📤 ОТПРАВКА ТЕСТОВЫХ ДАННЫХ:</h3>";
|
|||
|
|
echo "<p><strong>Клиент:</strong> Тестов Тест Тестович</p>";
|
|||
|
|
echo "<p><strong>Email:</strong> test@test.com</p>";
|
|||
|
|
echo "<p><strong>Телефон:</strong> 999 999-99-99</p>";
|
|||
|
|
|
|||
|
|
// Отправляем данные
|
|||
|
|
$curl = curl_init();
|
|||
|
|
curl_setopt_array($curl, [
|
|||
|
|
CURLOPT_URL => 'https://form.clientright.ru/server_webservice2.php',
|
|||
|
|
CURLOPT_RETURNTRANSFER => true,
|
|||
|
|
CURLOPT_POST => true,
|
|||
|
|
CURLOPT_POSTFIELDS => $data,
|
|||
|
|
CURLOPT_SSL_VERIFYPEER => false,
|
|||
|
|
CURLOPT_TIMEOUT => 30,
|
|||
|
|
CURLOPT_HTTPHEADER => [
|
|||
|
|
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
|||
|
|
]
|
|||
|
|
]);
|
|||
|
|
|
|||
|
|
$response = curl_exec($curl);
|
|||
|
|
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
|||
|
|
$error = curl_error($curl);
|
|||
|
|
curl_close($curl);
|
|||
|
|
|
|||
|
|
echo "<p><strong>HTTP код:</strong> " . $httpCode . "</p>";
|
|||
|
|
|
|||
|
|
if ($error) {
|
|||
|
|
echo "<p style='color: red;'><strong>Ошибка cURL:</strong> " . $error . "</p>";
|
|||
|
|
} else {
|
|||
|
|
echo "<p><strong>Ответ от server_webservice2.php:</strong></p>";
|
|||
|
|
echo "<pre>" . htmlspecialchars($response) . "</pre>";
|
|||
|
|
|
|||
|
|
// Парсим ответ
|
|||
|
|
$response_data = json_decode($response, true);
|
|||
|
|
if ($response_data) {
|
|||
|
|
echo "<h3>🎯 РЕЗУЛЬТАТ:</h3>";
|
|||
|
|
|
|||
|
|
if (isset($response_data['status']) && $response_data['status'] === 'success') {
|
|||
|
|
echo "<p style='color: green; font-weight: bold;'>✅ СТАТУС: УСПЕХ!</p>";
|
|||
|
|
echo "<p style='color: green; font-weight: bold;'>🎉 ТЕСТОВЫЙ КЛИЕНТ СОЗДАН!</p>";
|
|||
|
|
} else {
|
|||
|
|
echo "<p style='color: red; font-weight: bold;'>❌ ОШИБКА ПРИ СОЗДАНИИ КЛИЕНТА</p>";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo "<hr>";
|
|||
|
|
echo "<h3>🔍 ПРОВЕРКА ЛОГОВ:</h3>";
|
|||
|
|
|
|||
|
|
// Проверяем логи
|
|||
|
|
$log_file = '/var/www/fastuser/data/www/erv.clientright.ru/public_html/formlog/form_log.log';
|
|||
|
|
if (file_exists($log_file)) {
|
|||
|
|
echo "<p><strong>Лог файл найден:</strong> " . $log_file . "</p>";
|
|||
|
|
|
|||
|
|
// Читаем последние 20 строк лога
|
|||
|
|
$log_lines = file($log_file);
|
|||
|
|
$recent_lines = array_slice($log_lines, -20);
|
|||
|
|
|
|||
|
|
echo "<h4>Последние 20 строк лога:</h4>";
|
|||
|
|
echo "<pre style='background: #f5f5f5; padding: 10px; max-height: 400px; overflow-y: auto;'>";
|
|||
|
|
foreach ($recent_lines as $line) {
|
|||
|
|
echo htmlspecialchars($line);
|
|||
|
|
}
|
|||
|
|
echo "</pre>";
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
echo "<p style='color: red;'><strong>Лог файл не найден:</strong> " . $log_file . "</p>";
|
|||
|
|
echo "<p>Возможно, папка formlog не создается или нет прав на запись.</p>";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
echo "<hr>";
|
|||
|
|
echo "<h3>📋 АНАЛИЗ ОТПРАВЛЕННЫХ ДАННЫХ:</h3>";
|
|||
|
|
echo "<p><strong>Клиентские поля (ws_type='client'):</strong></p>";
|
|||
|
|
echo "<ul>";
|
|||
|
|
foreach ($appends as $key => $itemjson) {
|
|||
|
|
$item = json_decode($itemjson);
|
|||
|
|
if ($item->ws_type == "client") {
|
|||
|
|
echo "<li><strong>{$item->ws_name}:</strong> '{$item->field_val}'</li>";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
echo "</ul>";
|
|||
|
|
|
|||
|
|
echo "<hr>";
|
|||
|
|
echo "<p><strong>Тест завершен!</strong> Проверьте логи выше для детальной информации.</p>";
|
|||
|
|
?>
|