1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Common/Global.php');
|
---|
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 |
|
---|
29 | $Query = 'SELECT Id FROM News WHERE (`Title`="'.$Database->real_escape_string($Title).'") AND (`Category`='.$Category.') AND (`Content` = "'.$Database->real_escape_string($Description).'") AND (`Link` = "'.$Database->real_escape_string($Link).'")';
|
---|
30 | $DbResult = $Database->query($Query);
|
---|
31 | if($DbResult->num_rows == 0)
|
---|
32 | {
|
---|
33 | $Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
|
---|
34 | echo($Database->insert_id.',');
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | ?>
|
---|