core/parcer/leop.php

91 lines
3.3 KiB
PHP
Executable File

<?php
$_SERVER['SERVER_NAME']='tk-ligat.ru';
require_once('/home/cloud/core/set/tk-ligat.ru.php');
require_once('/home/cloud/core/api/php/db.php');
require_once('/home/cloud/core/api/php/json.php');
function leopak ($text) {
$old1 = array("http://");
$new1 = array("https://");
$text = str_replace($old1, $new1, $text);
return $text;
}
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "/categories/%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link='https://market.leopak.ru' . $LinkList[$i]['link'];
DB::set("UPDATE `sm` SET `link`=? WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "/productlist/%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link='https://market.leopak.ru' . $LinkList[$i]['link'];
DB::set("UPDATE `sm` SET `link`=?, `status`=1 WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "/news%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link='https://market.leopak.ru' . $LinkList[$i]['link'];
DB::set("UPDATE `sm` SET `link`=?, `status`=1 WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "/manufacturers%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link='https://market.leopak.ru' . $LinkList[$i]['link'];
DB::set("UPDATE `sm` SET `link`=?, `status`=1 WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "/search?%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link='https://market.leopak.ru' . $LinkList[$i]['link'];
DB::set("UPDATE `sm` SET `link`=?, `status`=1 WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "pictures/%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link='https://market.leopak.ru/' . $LinkList[$i]['link'];
DB::set("UPDATE `sm` SET `link`=?, `status`=1 WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "/newscategory/%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link='https://market.leopak.ru' . $LinkList[$i]['link'];
DB::set("UPDATE `sm` SET `link`=?, `status`=1 WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` LIKE "http://%"');
for ($i=0; $i<count( $LinkList ); $i++){
$link=leopak( $LinkList[$i]['link'] );
DB::set("UPDATE `sm` SET `link`=?, `status`=1 WHERE `id`=?", array($link, $LinkList[$i]['id']));
}
DB::set("UPDATE `sm` SET `status`=1 WHERE `link` LIKE 'https://market.leopak.ru%'");
//ищем дубли....
unset($LinkList);
$LinkList = DB::getAll( 'SELECT * FROM `sm` WHERE `link` NOT LIKE "https://market.leopak.ru/products/%" AND `link` LIKE "https://market.leopak.ru%"');
for ($i=0; $i<count( $LinkList ); $i++){
DB::set("DELETE FROM `sm` WHERE `link`=?", $LinkList[$i]['link']);
$link=leopak( $LinkList[$i]['link'] );
DB::add("INSERT INTO `sm` (`link`, `status`) VALUES (?, ?)", array($LinkList[$i]['link'], 1));
}
// select count(*) from `sm` where `md5` is not null
exec ("php /home/cloud/core/parcer/r3.php");
?>