38 lines
1.2 KiB
PHP
Executable File
38 lines
1.2 KiB
PHP
Executable File
<?php
|
|
function html_to_obj($html) {
|
|
$dom = new DOMDocument();
|
|
// $dom->loadHTML($html);
|
|
@$dom->loadHTML(mb_convert_encoding(@$html, 'HTML-ENTITIES', 'UTF-8'));
|
|
return element_to_obj($dom->documentElement);
|
|
}
|
|
|
|
function element_to_obj($element) {
|
|
@$obj = array( "tag" => @$element->tagName );
|
|
foreach (@$element->attributes as $attribute) {
|
|
$obj[$attribute->name] = $attribute->value;
|
|
}
|
|
foreach ($element->childNodes as $subElement) {
|
|
if ($subElement->nodeType == XML_TEXT_NODE) {
|
|
$obj["html"] = $subElement->wholeText;
|
|
}
|
|
else {
|
|
$obj["children"][] = element_to_obj($subElement);
|
|
}
|
|
}
|
|
return $obj;
|
|
}
|
|
function getCenaLeopak($donor, $tovar_id)
|
|
{
|
|
|
|
/* $homepage = file_get_contents($donor);
|
|
$cena= html_to_obj($homepage)['children'][1]['children'][8]['children'][5]['children'][0]['children'][3]['children'][0]['children'][0]['children'][0]['children'][0]['children'][0]['children'][0]['children'][0]['children'][0]['children'][1]['children'][0]['content'];
|
|
$new_cena=round($cena*1.5);
|
|
\DB::set("UPDATE `tovar` SET `cena`=?, `cena_d`=? WHERE `id`=?", array($new_cena, time(), $tovar_id));
|
|
return $new_cena;
|
|
//print_r($cena);
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
?>
|