89 lines
2.8 KiB
PHP
Executable File
89 lines
2.8 KiB
PHP
Executable File
<?php
|
|
|
|
|
|
|
|
require_once 'api/soft/phpQuery-master/phpQuery/phpQuery.php';
|
|
$html_leo = \core::get_page($page[0]['donor']);
|
|
$doc = phpQuery::newDocument($html_leo['html']);
|
|
$cena1 = $doc->find('.details-payment-cell .price .price-current .price-number');
|
|
$cena1=pq($cena1)->text();
|
|
|
|
|
|
if ($cena1){
|
|
$cena1 = round($cena1 * 1.5, 2);
|
|
$old_cena=$tovar['cena'];
|
|
if ($cena1<$old_cena) \DB::set("UPDATE `tovar` SET `cena`=?, `old_cena`=?, `status`=1 WHERE `id`=? LIMIT 1", array($cena1, $old_cena, $_GET['id']));
|
|
if (!$old_cena) \DB::set("UPDATE `tovar` SET `cena`=?, `status`=1 WHERE `id`=? LIMIT 1", array($cena1, $_GET['id']));
|
|
}else{
|
|
\DB::set("UPDATE `tovar` SET `status`=0 WHERE `id`=? LIMIT 1", $_GET['id']);
|
|
}
|
|
//Проверяем наличие картинки
|
|
$imgID=\DB::getValue("SELECT `id` FROM `tovar_img` WHERE `tovar_id`=?", $_GET['id']);//ОПТИМИЗИРОВАТЬ!!!
|
|
if (!$imgID){
|
|
$filename=\core::genpassword(30);
|
|
exec("wget " . $tovar['linkimg'] . " -O /home/cloud/core/img/tk-ligat.ru/leopak/" . $filename . ".jpg");
|
|
symlink("/home/cloud/core/img/tk-ligat.ru/leopak/" . $filename . ".jpg", "/home/cloud/core/img/tk-ligat.ru/tovar/" . $filename . ".jpg");
|
|
\DB::add("INSERT INTO `tovar_img` (`tovar_id`, `filename`) VALUES (?, ?)", array($_GET['id'], $filename));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
if ($html_leo['code'] == 200) {
|
|
$page[0]['cena'] = round(leopak($cena) * 1.3, 2);
|
|
|
|
\DB::set("UPDATE `tovar` SET `cena`=?, `status`=1 WHERE `id`=? LIMIT 1", array($page[0]['cena'], $_GET['id']));
|
|
} else {
|
|
|
|
\DB::set("UPDATE `tovar` SET `cena`=NULL, `status`=0 WHERE `id`=? LIMIT 1", $_GET['id']);
|
|
}
|
|
|
|
|
|
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'][5]['children'][1]['children'][0]['children'][0]['children'][2]['children'][3]['children'][1]['children'][0]['children'][0]['children'][3]['children'][0]['children'][0]['children'][0]['content'];
|
|
$new_cena=round($cena*1.6);
|
|
\DB::set("UPDATE `tovar` SET `cena`=?, `cena_d`=? WHERE `id`=?", array($new_cena, time(), $tovar_id));
|
|
return $new_cena;
|
|
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
?>
|