core/parcer/xmlimg.php

47 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2023-01-02 21:33:36 +05:00
<?php
require_once('/home/cloud/core/api/php/db.php');
require_once('/home/cloud/core/api/php/json.php');
DB::$type='sqlite3';
DB::$path='/home/cloud/core/bd/tk-ligat.ru.db';
function generate_password($number){
$arr = array('a','b','c','d','e','f', 'g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','x','y','z','1','2','3','4','5','6','7','8','9','0');
$pass = "";
for($i = 0; $i < $number; $i++){
$index = rand(0, count($arr) - 1);
$pass .= $arr[$index];
}
return $pass;
}
$current=file_get_contents('../goods_sur102215_dcc93d1672486819.xml');
$xml = simplexml_load_string($current, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
$tovar=$array['Товар'];
for ($i=0; $i<count($tovar); $i++){
$fotos=$tovar[$i]['Фотографии'][ото1500'];
if (count($fotos)==0) $fotos[0]=$tovar[$i]['Фотографии'][ото1500'];
$content=json::to_j($fotos);
file_put_contents('img/' . $tovar[$i]['@attributes']['код'] . '.txt', $content);
unset($insert);
unset($tovar_id);
unset($id);
unset($fotos);
unset($cena);
unset($check);
unset($doc_id);
unset($massiv);
unset($json);
}
?>