-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
54 lines (50 loc) · 1.73 KB
/
index.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
<?php
require './init.php';
if (isset($_GET['historyId'])) {
$historyId = intval($_GET['historyId']);
$oldData = $History->get($historyId);
$data = $oldData['data'];
}
if (isset($_GET['u'])) {
$data['url'] = $_GET['u'];
$data['name'] = $_GET['t'];
$data['description'] = $_GET['d'];
}
$versionUrl = 'http://jeck.ru/download/version.php?product=1';
if (!file_exists('./data/version.dat') || (filemtime('./data/version.dat') + 60*60*3) < time()) {
$lastVersion = file_get_contents($versionUrl);
file_put_contents('./data/version.dat', $lastVersion);
} else {
$lastVersion = file_get_contents('./data/version.dat');
}
//*
$feedUrl = 'http://jeck.ru/download/rss.php?product_id=1';
if (!file_exists('./data/feed.dat') || (filemtime('./data/feed.dat') + 60*60*3) < time()) {
file_put_contents('./data/feed.dat', file_get_contents($feedUrl));
}
function getInnerHTML($element) {
$innerHTML = "";
$children = $element->childNodes;
foreach ($children as $child) {
$tmp_dom = new DOMDocument();
$tmp_dom->appendChild($tmp_dom->importNode($child, true));
$innerHTML.=trim($tmp_dom->saveHTML());
}
return $innerHTML;
}
$doc = new DOMDocument();
$doc->load('./data/feed.dat');
$rss = array();
foreach ($doc->getElementsByTagName('item') as $node) {
$item = array (
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'description' => getInnerHTML($node->getElementsByTagName('description')->item(0)),
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'date' => date('d.m.Y', strtotime($node->getElementsByTagName('pubDate')->item(0)->nodeValue))
);
$rss[] = $item;
}
//*/
$title = '';
include './templates/index.php';
?>