Отправляем на сервер:
<?
$secret = 'DquEn!lw4j3k98SMS#sfud'; // придумываем ключ
$key1 = microtime(true);
$key2 = md5($key1.$secret);
$sendData = array(
'name' => $sUserName,
'phone' => $sUserPhone,
'station' => $sStationName,
'key1' => $key1,
'key2' => $key2,
);
$oCurl = curl_init();
curl_setopt($oCurl, CURLOPT_URL, "https://site.ru/request.php");
curl_setopt($oCurl, CURLOPT_POST, true);
curl_setopt($oCurl, CURLOPT_HEADER, false);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, false);
curl_setopt($oCurl, CURLOPT_POSTFIELDS, $sendData);
$result = curl_exec($oCurl);
curl_close($oCurl);
?>
Принимаем на сервере, файл request.php:
<?
$secret = 'DquEn!lw4j3k98SMS#sfud';
$key1 = $_POST['key1'];
$key2 = $_POST['key2'];
if(microtime(true) - $key1 > 300) die('Неверные ключи');
if($key2 != md5($key1.$secret)) die('Неверные ключи');
$name = strip_tags($_POST['name']);
$name = str_replace("\n", '', $name);
$name = str_replace(";", '', $name);
$name = trim($name);
$phone = strip_tags($_POST['phone']);
$phone = str_replace("\n", '', $phone);
$phone = str_replace(";", '', $phone);
$phone = trim($phone);
$station = strip_tags($_POST['station']);
$station = str_replace("\n", '', $station);
$station = str_replace(";", '', $station);
$station = trim($station);