add parser arriah.ru
This commit is contained in:
127
arriah.php
Normal file
127
arriah.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
include_once '/vhosts/beta/wp-load.php';
|
||||
|
||||
arriah_parser();
|
||||
|
||||
|
||||
function arriah_parser(){
|
||||
|
||||
global $wpdb;
|
||||
|
||||
|
||||
$feed = 'https://new.arriah.ru/rss.php';
|
||||
|
||||
|
||||
$arrContextOptions=array(
|
||||
"ssl"=>array(
|
||||
"verify_peer"=>false,
|
||||
"verify_peer_name"=>false,
|
||||
),
|
||||
);
|
||||
|
||||
$xml = file_get_contents($feed, false, stream_context_create($arrContextOptions));
|
||||
|
||||
$result = array();
|
||||
$res = array();
|
||||
|
||||
$xml = simplexml_load_string($xml);
|
||||
$n_old = 0;
|
||||
$nn = 0;
|
||||
|
||||
foreach ($xml->xpath('//item') as $item){
|
||||
|
||||
$link = (string)$item->link;
|
||||
$link = trim($link, '/');
|
||||
$f_end = strrpos($link,'/');
|
||||
|
||||
if ($f_end){
|
||||
$code = substr($link, $f_end+1);
|
||||
}
|
||||
else
|
||||
continue;
|
||||
|
||||
|
||||
if (isset($find_news['ID'])){
|
||||
$n_old++;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
|
||||
$date = (string)$item->pubDate;
|
||||
$mysqldate = date('Y-m-d H:i:s',strtotime($date));
|
||||
|
||||
$title = (string)$item->title;
|
||||
$title = wp_strip_all_tags($title);
|
||||
$text = (string)$item->description;
|
||||
$text = str_replace('src="/local/', 'src="https://new.arriah.ru/local/', $text);
|
||||
//$text = replace_br($text);
|
||||
//$text = delete_p($text);
|
||||
$text = str_replace('<br>', '<br><br>', $text);
|
||||
$slug = express_slug(vij_slug($title));
|
||||
|
||||
$sql = "SELECT `ID` from `wp_posts` WHERE `post_name` = '$slug' and `post_date` = '$mysqldate'";
|
||||
$result = $wpdb->get_results($sql);
|
||||
|
||||
if ($result) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$my_post = [
|
||||
'post_title' => $title,
|
||||
'post_name' => $slug,
|
||||
'post_type' => 'post',
|
||||
'post_content' => $text,
|
||||
'post_date' => $mysqldate,
|
||||
'post_status' => 'publish',
|
||||
'post_author' => 1,
|
||||
'comment_status' => 'closed',
|
||||
'post_category' => array( 37 )
|
||||
];
|
||||
|
||||
wp_insert_post( $my_post);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return True;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function file_get_contents_curl( $url ) {
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt( $ch, CURLOPT_AUTOREFERER, TRUE );
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0 );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_URL, $url );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, TRUE );
|
||||
|
||||
$data = curl_exec( $ch );
|
||||
curl_close( $ch );
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function replace_br($html) {
|
||||
|
||||
$html = preg_replace('#(?:<br\s*/?>\s*?){2,}#', '</p><p>', $html);
|
||||
return "<p>$html</p>";
|
||||
|
||||
}
|
||||
|
||||
function delete_p($html){
|
||||
|
||||
$pattern = "/<p[^>]*><\\/p[^>]*>/";
|
||||
return preg_replace($pattern, '', $html);
|
||||
|
||||
}
|
||||
@@ -46,6 +46,7 @@ $nn = 0;?>
|
||||
<a href="<?the_permalink();?>"><img class="mini-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'full'); ?>" alt="<?the_title();?>"></a>
|
||||
<?endif?>
|
||||
<h2 class="mini-card-title"><a href="<?the_permalink();?>"><?the_title();?></a></h2>
|
||||
<div><a href="<?the_permalink();?>"><?the_excerpt();?></a></div>
|
||||
<div class="mini-card-body">
|
||||
<div class="news_date"><?the_time('j F Y, G:i');?></div>
|
||||
</div>
|
||||
|
||||
93
single-37.php
Normal file
93
single-37.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php get_header();?>
|
||||
|
||||
|
||||
|
||||
|
||||
<div id="content">
|
||||
|
||||
<?//while(have_posts()):?>
|
||||
<?the_post();?>
|
||||
|
||||
|
||||
<?php $category = get_the_category();
|
||||
$category_id = $category[0]->term_id;
|
||||
$category_link = get_category_link($category_id);
|
||||
$post_id = get_the_ID();
|
||||
?>
|
||||
|
||||
<ul id="nav_content">
|
||||
<li><a href="<?=get_site_url()?>">Главная</li>
|
||||
<li>-<li>
|
||||
<li><a href="<?=$category_link?>"><?=$category['0']->name;?></a></li>
|
||||
<li>-<li>
|
||||
<li><?=mb_substr(get_the_title(), 0, 50);?>...</li>
|
||||
</ul>
|
||||
|
||||
<div class="post_info">
|
||||
<div class="post_info_sub">
|
||||
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category['0']->name;?></a></span>, <nobr><?php the_time('j F Y, G:i');?></nobr>
|
||||
</div>
|
||||
<div class="post_info_sub post_info_social">
|
||||
<?php include get_template_directory().'/blocks/social-share.php';?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="fulltext">
|
||||
<h1 class="post-h1"><?php wp_title('');?></h1>
|
||||
<?$author = get_the_author();
|
||||
if ( ! empty ( $author ) AND $author !== 'vetandlife.ru'):?>
|
||||
<div class="post_author">
|
||||
Автор: <?=the_author_posts_link()?>
|
||||
</div>
|
||||
<?endif?>
|
||||
|
||||
<?if ( has_post_thumbnail() ) :?>
|
||||
<div id="post-img">
|
||||
<img class="img-fluid rounded" src="<?php echo get_the_post_thumbnail_url(null, 'full');?>" alt="<?the_title();?>">
|
||||
</div>
|
||||
<div class="post_img_title"><?the_post_thumbnail_caption()?></div>
|
||||
<?endif?>
|
||||
<div class="fulltext">
|
||||
<?the_content();?>
|
||||
</div>
|
||||
|
||||
<div class="post_panel_info">
|
||||
<div class="post_panel_info_sub">
|
||||
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category['0']->name;?></a></span>, <nobr><?php the_time('j F Y, G:i');?></nobr>
|
||||
</div>
|
||||
<div class="post_panel_info_sub">
|
||||
<!--Поделиться <i class="fas fa-share-square btn_soc_post"></i>--> <?php include get_template_directory().'/blocks/social-share.php';?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="promo-agregators">
|
||||
<p>Свежие отраслевые новости на нашем канале в <span class="promo-telega"><a href="https://t.me/ViZHuvizh" target="_blank">Telegram</a></span></p>
|
||||
<p>Добавьте «Ветеринарию и жизнь» в избранное в <a href="https://yandex.ru/news/?favid=254162793" target="_blank"><span class="promo_ya">Я</span><span style="font-weight: bold; color:black;">НДЕКС.НОВОСТИ</span></a></p>
|
||||
<p>Подписывайтесь на канал «ВиЖ» в <b><a href="https://zen.yandex.ru/id/5ee3cb4d4954b90c587dec79" target="_blank"><span class="promo_ya">Я</span>НДЕКС.ДЗЕН</a></b></p>
|
||||
</div>
|
||||
<!--<p><small class="text-muted"><?php the_tags('');?></small></p> -->
|
||||
<?//endwhile;?>
|
||||
|
||||
<?php include get_template_directory().'/blocks/yets.php';?>
|
||||
|
||||
<div id="tags">
|
||||
<?php the_tags();?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php include get_template_directory().'/blocks/moread.php';?>
|
||||
|
||||
<div class="publ-to-main">
|
||||
<button class="more_button" onclick="location.href='<?=get_site_url()?>/page/2'" type="button">
|
||||
На главную</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php get_footer();?>
|
||||
Reference in New Issue
Block a user