source: trunk/Modules/News/ImportZdechovCzNews.php@ 607

Last change on this file since 607 was 548, checked in by chronos, 12 years ago
  • Odstraněno: Ukončovací PHP značka.
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/../../Common/Global.php');
4
5$SourceURL = 'http://www.zdechov.cz/';
6$StartText = '<tr class="even">';
7$StartLink = 'href="';
8$StartTitle = '>';
9$TitleSeparator = '"';
10$StartDescription = '';
11$StartDate = '<td align="right">';
12$Category = 12;
13$Author = 'Automat';
14$Content = file_get_contents($SourceURL);
15while(strpos($Content, $StartText) !== false)
16{
17 $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
18 $Content = substr($Content, strpos($Content, $StartDate) + strlen($StartDate));
19 $Date = substr($Content, 0, strpos($Content, '<'));
20 $DateParts = explode('.', $Date);
21 $Date = $DateParts[2].'-'.$DateParts[1].'-'.$DateParts[0];
22 $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink));
23 $Link = substr($Content, 0, strpos($Content, '"'));
24 if(substr($Link, 0, 7) != 'http://') $Link = 'http://www.zdechov.cz/'.$Link;
25 $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle));
26 $Title = substr($Content, 0, strpos($Content, '<'));
27 $Description = '';
28
29
30 /*
31 echo('Title: '.$Title.'<br>');
32 echo('Description: '.$Description.'<br>');
33 echo('Date: '.$Date.'<br>');
34 echo('Link: '.$Link.'<br><hr>');
35 */
36
37 $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category);
38 //echo($System->Database->LastQuery);
39 if($DbResult->num_rows == 0)
40 {
41 $System->Database->insert('News', array('Title' => $Title, 'Date' => $Date, 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link));
42 echo($System->Database->insert_id.',');
43 }
44}
Note: See TracBrowser for help on using the repository browser.