Ignore:
Timestamp:
Nov 27, 2011, 6:31:35 PM (13 years ago)
Author:
chronos
Message:
  • Opraveno: Do třídy databáze doplněny další funkce z dřívější mysqli.
  • Upraveno: Přepracován import aktualit zděchova.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/aktuality/import_zdechov_cz_aktuality.php

    r310 r320  
    33include('../global.php');
    44
    5 $SourceURL = 'http://www.zdechov.cz/pages/main.php?pg=home&cat=1';
    6 $StartText = '<table width=100% border=0 cellspacing=1 cellpadding=5><tr><td bgcolor=#567069><b>';
    7 $TitleSeparator = '<tr>';
    8 $StartDescription = '<tr><td bgcolor=#567069>';
    9 $StartDate = 'vloženo: ';
     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">';
    1012$Category = 12;
    1113$Author = 'Automat';
    12 
    13 $Content = addslashes(ToUTF8(file_get_contents($SourceURL), 'win1250'));
     14$Content = file_get_contents($SourceURL);
    1415while(strpos($Content, $StartText) !== false)
    1516{
    1617  $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText));
    17   $Title = substr($Content, 0, strpos($Content, $TitleSeparator));
    18   $Content = substr($Content, strpos($Content, $StartDescription) + strlen($StartDescription));
    19   $Description = substr($Content, 0, strpos($Content, $TitleSeparator));
    2018  $Content = substr($Content, strpos($Content, $StartDate) + strlen($StartDate));
    21   $Date = substr($Content, 0, strpos($Content, ' '));
     19  $Date = substr($Content, 0, strpos($Content, '<'));
    2220  $DateParts = explode('.', $Date);
    2321  $Date = $DateParts[2].'-'.$DateParts[1].'-'.$DateParts[0];
    24   $Link = 'http://www.zdechov.cz/pages/main.php?pg=home&cat=1';
     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://'.$Link;
     25  $Content = substr($Content, strpos($Content, $StartTitle) + strlen($StartTitle));
     26  $Title = substr($Content, 0, strpos($Content, '<'));
     27  $Description = '';
     28 
    2529
    26 
    27 /*
    2830  echo('Title: '.$Title.'<br>');
    2931  echo('Description: '.$Description.'<br>');
    3032  echo('Date: '.$Date.'<br>');
    3133  echo('Link: '.$Link.'<br><hr>');
    32 */
     34
    3335
    3436  $DbResult = $Database->select('News', 'Id', '`Title`="'.$Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category);
Note: See TracChangeset for help on using the changeset viewer.