$file_put = __DIR__ . "/../../log/xml/ExportReport" . $acc . "_" . $currDate . ".xml";
+ if (empty($html)) {
+ echo "<br><font color=red>Пустой ответ от API для $currDate (acc=$acc)</font>";
+ $currDate = date("Y-m-d", strtotime("+1 day", strtotime($currDate)));
+ continue;
+ }
+
file_put_contents($file_put, $html);
//echo"<textarea class=\"form-control\">$html</textarea>";
$json = json_decode($html, true, 512, JSON_UNESCAPED_UNICODE);
//echo" ".$json["Error"]."";
+ libxml_use_internal_errors(true);
$xml = simplexml_load_file($file_put);
+ if ($xml === false) {
+ echo "<br><font color=red>Невалидный XML для $currDate (acc=$acc)</font>";
+ libxml_clear_errors();
+ $currDate = date("Y-m-d", strtotime("+1 day", strtotime($currDate)));
+ continue;
+ }
+ libxml_clear_errors();
$maas = json_decode(json_encode($xml), true);
asort($maas);
foreach ($maas["count"] ?? [] as $id => $arr) {
$filename = 'file_cnt.txt';
- file_put_contents(__DIR__ . '/../../log/text/' . $filename, $currDate . "" . date("Y-m-d H:i:s") . "");
+ $logTextDir = __DIR__ . '/../../log/text';
+ if (!is_dir($logTextDir)) {
+ mkdir($logTextDir, 0777, true);
+ }
+ file_put_contents($logTextDir . '/' . $filename, $currDate . "" . date("Y-m-d H:i:s") . "");
if ($all) {
arsort($all);
foreach ($all as $cid => $val) echo "<br> $cid = > $val "; ///".$allcnt[$cid]."