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