Changeset 320


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.
Location:
trunk
Files:
1 deleted
2 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);
  • trunk/database.php

    r319 r320  
    3333  var $PDO;
    3434  var $Error = '';
     35  var $insert_id;
     36  var $LastQuery = '';
    3537 
    3638  function __construct($Host, $User, $Password, $Database)
     
    5153    global $Config;
    5254       
     55    $this->LastQuery = $Query;
    5356    if($Config['Web']['ShowSQLQuery'] == true)
    5457      echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'."\n");
     
    8588    $Values = substr($Values, 1);
    8689    $this->PDO->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
     90    $this->insert_id = $this->PDO->lastInsertId();
    8791  }
    8892 
     
    121125  }
    122126 
     127  function real_escape_string($Text)
     128  {
     129    return(addslashes($Text));
     130  }
     131 
    123132}
    124133
Note: See TracChangeset for help on using the changeset viewer.