1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Application/Core.php');
|
---|
4 | $System = new Core();
|
---|
5 | $System->ShowPage = false;
|
---|
6 | $System->Run();
|
---|
7 |
|
---|
8 | $SourceURL = 'http://dviproduction.cz/video/playlist.xml';
|
---|
9 | $StartText = '<item>';
|
---|
10 | $TitleSeparator = '<title>';
|
---|
11 | $DescriptionSeparator = '<description>';
|
---|
12 | $StartLink = 'url="';
|
---|
13 | $Category = 13;
|
---|
14 | $Author = 'Automat';
|
---|
15 |
|
---|
16 | //$Encoding = new Encoding();
|
---|
17 | //$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250'));
|
---|
18 | $Content = @file_get_contents($SourceURL);
|
---|
19 | while (strpos($Content, $StartText) !== false)
|
---|
20 | {
|
---|
21 | $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
|
---|
22 | $Title = substr($Content, strpos($Content, $TitleSeparator) + strlen($TitleSeparator));
|
---|
23 | $Title = substr($Title, 0, strpos($Title, '<'));
|
---|
24 |
|
---|
25 | $Description = substr($Content, strpos($Content, $DescriptionSeparator) + strlen($DescriptionSeparator));
|
---|
26 | $Description = trim(substr($Description, 0, strpos($Description, '<')));
|
---|
27 |
|
---|
28 | $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink));
|
---|
29 | $Link = substr($Content, 0, strpos($Content, '"'));
|
---|
30 | // $Link = substr($Link, 0, strpos($Link, '?')); // Remove URL parameters
|
---|
31 | // $Link = substr($Link, 0, strrpos($Link, '/')).substr($Link, strrpos($Link, '/')); // Insert month between folder and filename
|
---|
32 |
|
---|
33 | //echo('Title: '.$Title.'<br>');
|
---|
34 | //echo('Description: '.$Description.'<br>');
|
---|
35 | //echo('Link: '.$Link.'<br><hr>');
|
---|
36 |
|
---|
37 | $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Category`='.$Category);
|
---|
38 | //echo($System->Database->LastQuery);
|
---|
39 | if ($DbResult->num_rows == 0)
|
---|
40 | {
|
---|
41 | $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
|
---|
42 | echo($System->Database->insert_id.',');
|
---|
43 | }
|
---|
44 | }
|
---|