
Код:
<?php
$recip = "my_mail@gmail.com";
$document = file("my.xml");
// ************ ТУТ ПРОБЛЕМА ***********
//$document = file_get_contents("php://input");
/// ************ ТУТ ПРОБЛЕМА ***********
// headers
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: do_not_reply@domain.com";
// contact
$client_name;
$client_surname;
$client_phone;
$client_mail;
$client_address;
// arrays
$window_widths = array();
$window_heights = array();
$window_color = array();
$window_quant = array();
$window_acc = array();
$count = 0;
function opening_element($parser, $element, $attributes) {
global $window_widths, $window_heights, $window_color, $window_quant, $window_acc;
global $client_name, $client_surname, $client_phone, $client_mail, $client_address;
///
if ($element == "order"){
$client_name = $attributes["client_name"];
$client_surname = $attributes["client_surname"];
$client_phone = $attributes["client_phone"];
$client_mail = $attributes["client_mail"];
$client_address = $attributes["client_address"];
}
if ($element == "window"){
$window_heights[] = $attributes["window_height"];
$window_widths[] = $attributes["window_width"];
$window_color[] = $attributes["window_color"];
$window_quant[] = $attributes["window_quant"];
$window_acc[] = $attributes["window_acc"];
}
}
function closing_element($parser, $element) {
}
function character_data($parser, $data) {
}
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($parser, "opening_element", "closing_element");
xml_set_character_data_handler($parser, "character_data");
//******* Next Line is Nr. 58
foreach ($document as $line) {
xml_parse($parser, $line);
}
xml_parser_free($parser);
$msg = str_replace("\r", "\n", $msg);
$sender = $_SERVER[REMOTE_ADDR];
$msg = "<b>Contact form send by: <br> Name : $client_name <br> Surname : $client_surname <br> Phone : $client_phone <br> Email: $client_mail <br> Address: $client_address</b> <br><br> Order:<br>";
$msg.="<tr>
<td>Nr.</td>
<td>1. Width x Height</td>
<td>2. Width x Height</td>
<td>3. Width x Height</td>
<td>Color</td>
<td>Accessories</td>
<td>Quantaty</td>
</tr>";
$total_w=count($window_widths);
for ($i = 0; $i < $total_w; $i++) {
$msg.="<tr>
<td width=\"25\">$i</td>
<td>$window_widths[$i] x $window_heights[$i]</td>
<td>$window_widths[$i] x $window_heights[$i]</td>
<td>$window_widths[$i] x $window_heights[$i]</td>
<td>$window_color[$i]</td>
<td>$window_acc[$i]</td>
<td>$window_quant[$i]</td>
</tr>";
}
$msg.="<br>Sender's IP: $sender";
mail($recip, "Order form", $msg, $headers);
?>
Люди добрые выручите пожалуйста.
Этот скрипт работает абсолютно верно когда использую $document = file("my.xml"); А когда $document = file_get_contents("php://input"); (Передаю ХМЛ из Флэша) тогда выдает такую ошибку:
Цитата:
|
Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/test/httpdocs/send_order.php on line 58
|
Как сделать так чтоб он парсил ХМЛ который пришел из Флэша?
Спасибо.