forked from darkalchemy/Pu-239
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtfreak.php
63 lines (58 loc) · 2.35 KB
/
tfreak.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
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @return mixed|string
*/
function rsstfreakinfo()
{
require_once INCL_DIR . 'html_functions.php';
global $site_config, $cache;
$html = '';
$use_limit = true;
$limit = 5;
$i = 0;
$xml = $cache->get('tfreaknewsrss_');
if ($xml === false || is_null($xml)) {
$xml = fetch('http://feed.torrentfreak.com/Torrentfreak/');
$cache->set('tfreaknewsrss_', $xml, 300);
}
$doc = new DOMDocument();
@$doc->loadXML($xml);
$items = $doc->getElementsByTagName('item');
foreach ($items as $item) {
$top = $i >= 1 ? 'top20' : '';
$html .= "
<div class='bordered $top'>
<div id='" . md5($item->getElementsByTagName('title')->item(0)->nodeValue) . "' class='header alt_bordered bg-00 has-text-left'>
<div class='has-text-primary size_5 padding10'>
" . htmlsafechars($item->getElementsByTagName('title')->item(0)->nodeValue) . "
</div>
<div class='bg-02 round5 padding10'>
<div class='bottom20 size_2 has-text-primary'>
by " . str_replace(['<![CDATA[', ']]>'], '', htmlsafechars($item->getElementsByTagName('creator')->item(0)->nodeValue)) . ' on ' . htmlsafechars($item->getElementsByTagName('pubDate')->item(0)->nodeValue) . '
</div>
<div>' . str_replace(['<![CDATA[', ']]>', 'href="'], ['', '', 'href="' . $site_config['anonymizer_url']], preg_replace('/<p>/', "<p class='has-text-white'>", $item->getElementsByTagName('description')->item(0)->nodeValue, 1)) . "
<a href='{$site_config['anonymizer_url']}" . $item->getElementsByTagName('link')->item(0)->nodeValue . "' target='_blank'>
<span class='size_2 has-text-primary'>
Read more
</span>
</a>
</div>
</div>
</div>
</div>";
if ($use_limit && ++$i >= $limit) {
break;
}
}
$html = str_replace([
'“',
'”',
], '"', $html);
$html = str_replace([
'’',
'‘',
'‘',
], "'", $html);
$html = str_replace('–', '-', $html);
return $html;
}