Last active
October 4, 2020 08:00
-
-
Save YakovSPb/cc08557928008d3a8d328b41f2537a0e to your computer and use it in GitHub Desktop.
Отправка данные form 7 в 1С
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Отправка данные form 7 в 1С | |
================================== | |
//Send to 1C | |
function.php | |
//Send to 1C form7 id 5 | |
function send_info_to1c_id5(){ | |
$url = trim($_POST["url-777"]); | |
$url = explode('?', $url); | |
$url = preg_replace('/^(https?:)?(\/\/)?(www\.)?/', '', $url); | |
$name = trim($_POST["text-name"]); | |
$phone = trim($_POST["text-67"]); | |
$text = trim($_POST["txt"]); | |
$username = "webuser"; | |
$password = "LSnop10"; | |
$data = array( | |
'name' => $name, | |
'phone'=> $phone, | |
'text' => $text, | |
'url' => $url[0] | |
); | |
if($phone !== ''){ | |
$ch = curl_init(); | |
$data_str = json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); | |
curl_setopt($ch, CURLOPT_URL, "https://79.134.223.44:37817/LS/hs/requests/create/"); | |
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_str); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
// SSL !!! | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | |
curl_setopt($ch, CURLOPT_CAINFO, WP_CONTENT_DIR . "/ssl/1c.pem"); | |
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 10); | |
curl_setopt ($ch, CURLOPT_TIMEOUT, 10); | |
$output = curl_exec($ch); | |
//echo('<pre>' . $output . '</pre>'); | |
if($output === false) { | |
//echo 'Ошибка curl: ' . curl_error($ch); | |
error_log('[' . date('Y-m-d H:i:s') . '] [error] Ошибка curl: (' . curl_errno($ch) . ') ' . curl_error($ch), 3, WP_CONTENT_DIR . "/curl.error.log"); | |
} | |
curl_close($ch); | |
/*if ($output === true){ | |
echo 'fired'; | |
}*/ | |
} | |
} | |
add_action( 'wpcf7_before_send_mail', 'send_info_to1c_id5'); | |
JS | |
====================== | |
//SEND URL TO 1C | |
jQuery('.wpcf7-submit').click(function(){ | |
var hiddenInput= jQuery(this).next().next().next().find('.hidden'); | |
var url = window.location.href; | |
url = url.split('?')[0]; | |
hiddenInput.val(url); | |
}) | |
CSS | |
================== | |
/* YAK STYLES */ | |
.yak_hidden{ | |
display: none; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment