| 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://www.dkvsetin.cz/rss/kino/8';
|
|---|
| 9 | $StartText = '<item>';
|
|---|
| 10 | $TitleSeparator = '<title>';
|
|---|
| 11 | $DescriptionSeparator = '<description>';
|
|---|
| 12 | $StartLink = '<link>';
|
|---|
| 13 | $Category = 15;
|
|---|
| 14 | $Author = 'Automat';
|
|---|
| 15 |
|
|---|
| 16 | $doc = new DOMDocument();
|
|---|
| 17 | $doc->load($SourceURL);
|
|---|
| 18 | foreach ($doc->getElementsByTagName('item') as $node)
|
|---|
| 19 | {
|
|---|
| 20 | $Title = $node->getElementsByTagName('title')->item(0)->nodeValue;
|
|---|
| 21 | $Description = $node->getElementsByTagName('description')->item(0)->nodeValue;
|
|---|
| 22 | $Link = $node->getElementsByTagName('link')->item(0)->nodeValue;
|
|---|
| 23 | $Date = $node->getElementsByTagName('pubDate')->item(0)->nodeValue;
|
|---|
| 24 |
|
|---|
| 25 | $Description = strip_tags($Description);
|
|---|
| 26 | $Description = str_replace("\r", '', $Description);
|
|---|
| 27 | $Description = str_replace("\n", '<br>', $Description);
|
|---|
| 28 | //if (($CommaPos = strpos($Date, ',')) !== FALSE)
|
|---|
| 29 | // $Date = substr($Date, $CommaPos + 1);
|
|---|
| 30 | $Date = TimeToMysqlDateTime(strtotime($Date));
|
|---|
| 31 |
|
|---|
| 32 | $Query = 'SELECT Id FROM News WHERE (`Title`="'.$System->Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$System->Database->real_escape_string($Description).'") AND (`Link` = "'.$System->Database->real_escape_string($Link).'")';
|
|---|
| 33 | $DbResult = $System->Database->query($Query);
|
|---|
| 34 | if ($DbResult->num_rows == 0)
|
|---|
| 35 | {
|
|---|
| 36 | $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
|
|---|
| 37 | echo($System->Database->insert_id.',');
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|