-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot.php
51 lines (39 loc) · 1.08 KB
/
robot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/*
* Persian Link CMS
* Powered By www.PersianLinkCMS.ir
* Author : Mohammad Majidi & Mahdi Yousefi (MahdiY.ir)
* Version 3.0
* copyright 2011 - 2018
*/
use App\Models\Feed;
use App\Models\Link;
include('vendor/autoload.php');
set_time_limit(60);
if (get_option('robo_status') == 1):
/** @var Feed[] $feeds */
$feeds = Feed::Active()->orderBy('time', 'DESC')->get();
foreach ($feeds as $feed) {
$rss = new SimplePie();
$rss->set_feed_url($feed->link);
$rss->enable_cache(false);
$rss->set_output_encoding('utf-8');
$rss->init();
/** @var SimplePie_Item[] $rss_item */
$rss_item = (object)array_reverse((array)$rss->get_items());
foreach ($rss_item as $item) {
$title = htmlentities($item->get_title());
$count = Link::where('title', $title)->count();
if ($count == 0 && filter_var($item->get_permalink(), FILTER_VALIDATE_URL)) {
Link::create([
'title' => $title,
'url' => $item->get_permalink(),
'time' => time(),
'date' => date("d-m-Y"),
'status' => 1,
]);
}
}
$feed->update(['time' => time()]);
}
endif;