Имеется скрипт
$xml = "<?xml version='1.0' encoding='UTF-8'?>
<data>
<login>*****</login>
<password>******</password>
<action>send</action>
<text>ТЕКСТ</text>
<to number='" . $_POST['number'] . "'></to>
</data>";
$address = "https://lcab.smsint.ru/API/XML/send.php";
$ch = curl_init($address);
curl_setopt($ch, CURLOPT_URL, $address);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
?>
Который отсылает СМС с указным текстом в поле
ТЕКСТ
необходимо чтобы в смс был указан логин и пароль указанный в базе данных MYSQL (В зависимости от клиента, где логин и номер телефона совпадают, причем вывод логина в смс необязательный)
в базе данных MYSQL - данные попадают из XML файл, в нем тоже есть пароль или логин пользователя
Как легче сделать вывод пароля в смс? и какой код нужно прописать? в строке
<text>ТЕКСТ</text>
также есть код как
<?php
function serializeme($source){
if(is_a($source, "SimpleXMLElement")){
$stdClass = new stdClass();
$stdClass->type = get_class($source);
$stdClass->data = $source->asXml();
}
return serialize($stdClass);
};
chdir('/****/****/domains/*******/xmlparse/');
$files = glob('*.xml');
if (!file_exists($files[0])) {
echo '<h1>Ошибка!</h1>Файл .xml не найден.<br />Загрузите в папку
/domains/******/xmlparse файл с расширением .xml';
}
else {
foreach($files as $file) {
$res = simplexml_load_file($file);
$count = 0;
foreach($res as $student) {
$count++;
//var_dump($student->ДанныеКурсанта->ДанныеСекретарь['Секретарь']);exit();
$student_id = (string)$student['GUID'];
$student_name = (string)$student->ДанныеКурсанта['ФИО'];
$student_group = (string)$student->ДанныеКурсанта['Группа'];
$student_login = (string)$student->ДанныеАвторизации['Логин'];
$student_password = (string)$student->ДанныеАвторизации['Пароль'];
$student_start = (string)$student->ДанныеОбОбучении['ДатаНачалаОбучения'];
$student_end = (string)$student->ДанныеОбОбучении['ДатаОкончанияОбучения'];
//-------------------------new-------------------//
$student_phone = (string)$student->ДанныеКурсанта['НомерТелефона'];
$student_gear = (string)$student->ДанныеКурсанта['ВидТрансмиссии'];
$student_summ = (string)$student->ДанныеКурсанта['СуммаДоговора'];
$student_debt = (string)$student->ДанныеКурсанта['Задолженность'];
$student_office = (string)$student->ДанныеКурсанта['Подразделение'];
$student_img = (string)$student->ДанныеКурсанта['ИмяФайла'];
$secretary_name = (string)$student->ДанныеКурсанта->ДанныеСекретарь['Секретарь'];
$secretary_img = (string)$student->ДанныеКурсанта->ДанныеСекретарь['ИмяФайла'];
$secretary_phone = (string)$student->ДанныеКурсанта->ДанныеСекретарь['НомерТелефона'];
$instructor_name = (string)$student->ДанныеКурсанта->ДанныеИнструктор['Инструктор'];
$instructor_phone = (string)$student->ДанныеКурсанта->ДанныеИнструктор['НомерТелефона'];
$instructor_auto = (string)$student->ДанныеКурсанта->ДанныеИнструктор['Автомобиль'];
$instructor_number = (string)$student->ДанныеКурсанта->ДанныеИнструктор['ГосНомер'];
$schedule = $student->ДанныеОбОбучении->ГрафикВождения;
$schedule = serializeme($schedule);
$connection = mysql_connect("localhost", "xn7sbah4", "Z3sb7gvq");
$student_id = mysql_real_escape_string($student_id);
$student_name = mysql_real_escape_string($student_name);
$student_group = mysql_real_escape_string($student_group);
$student_login = mysql_real_escape_string($student_login);
$student_password = mysql_real_escape_string($student_password);
$student_start = mysql_real_escape_string($student_start);
$student_end = mysql_real_escape_string($student_end);
$student_phone = mysql_real_escape_string($student_phone);
$student_gear = mysql_real_escape_string($student_gear);
$student_summ = mysql_real_escape_string($student_summ);
$student_debt = mysql_real_escape_string($student_debt);
$student_office = mysql_real_escape_string($student_office);
$student_img = mysql_real_escape_string($student_img);
$secretary_name = mysql_real_escape_string($secretary_name);
$secretary_img = mysql_real_escape_string($secretary_img);
$secretary_phone = mysql_real_escape_string($secretary_phone);
$instructor_name = mysql_real_escape_string($instructor_name);
$instructor_phone = mysql_real_escape_string($instructor_phone);
$instructor_auto = mysql_real_escape_string($instructor_auto);
$instructor_number = mysql_real_escape_string($instructor_number);
mysql_query("SET NAMES utf8");
if($connection == false)
$error = 'Нет подключения к базе';
else {
$db = mysql_select_db("********", $connection);
$query = mysql_query("select * from garaj_students where sid='$student_id'", $connection);
$student_id_check = mysql_fetch_assoc($query);
if($student_id_check["sid"]) {
//обновляем существующего
//echo "<b>Совпадение id: </b>".$student_id_check["sid"]."<br />";
$s_name = $student_name;
$s_group = $student_group;
$s_login = $student_login;
$s_password = $student_password;
$s_start = $student_start;
$s_end = $student_end;
$s_education = $schedule;
$s_phone = $student_phone;
$s_gear = $student_gear;
$s_summ = $student_summ;
$s_debt = $student_debt;
$s_office = $student_office;
$s_img = $student_img;
$s_sname = $secretary_name;
$s_simg = $secretary_img;
$s_phone = $secretary_phone;
$i_name = $instructor_name;
$i_phone = $instructor_phone;
$i_auto = $instructor_auto;
$i_number = $instructor_number;
$query = mysql_query("UPDATE `garaj_students
SET
`fio`='".$s_name."',
`group`='".$s_group."',
`login`='".$s_login."',
`password`='".$s_password."',
`start_education`='".$s_start."',
`end_education`='".$s_end."',
`student_phone`='".$s_phone."',
`student_gear`='".$s_gear."',
`student_summ`='".$s_summ."',
`student_debt`='".$s_debt."',
`student_office`='".$s_office."',
`student_img`='".$s_img."',
`secretary_name`='".$s_sname."',
`secretary_img`='".$s_simg."',
`secretary_phone`='".$s_phone."',
`schedule_education`='".$s_education."',
`instructor_name`='".$i_name."',
`instructor_phone`='".$i_phone."',
`instructor_auto`='".$i_auto."',
`instructor_number`='".$i_number."'
WHERE
`sid` = '".$student_id."'",
$connection) or die(mysql_error());
}
else {
//добавляем нового
$sql = "INSERT INTO `garaj_students` (`sid`, `fio`, `group`, `login`,
`password`, `start_education`, `end_education`, `student_phone`,
`student_gear`, `student_summ`, `student_debt`, `student_office`,
`student_img`, `secretary_name`, `secretary_img`,
`secretary_phone`,`schedule_education`, `instructor_name`,
`instructor_phone`, `instructor_auto`, `instructor_number`)
VALUES ('".$student_id."', '".$student_name."',
'".$student_group."', '".$student_login."', '".$student_password."',
'".$student_start."', '".$student_end."', '".$student_phone."',
'".$student_gear."', '".$student_summ."', '".$student_debt."',
'".$student_office."', '".$student_img."', '".$secretary_name."',
'".$secretary_img."', '".$secretary_phone."', '".$s_education."',
'".$i_name."', '".$i_phone."', '".$i_auto."', '".$i_number."')";
$query = mysql_query($sql, $connection) or die (mysql_error());
}
}}
//unlink($file);
echo '<br />Обработано записей: ' . $count;
}}
?>
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости