- Timestamp:
- Nov 27, 2011, 6:31:35 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/aktuality/import_zdechov_cz_aktuality.php
r310 r320 3 3 include('../global.php'); 4 4 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">'; 10 12 $Category = 12; 11 13 $Author = 'Automat'; 12 13 $Content = addslashes(ToUTF8(file_get_contents($SourceURL), 'win1250')); 14 $Content = file_get_contents($SourceURL); 14 15 while(strpos($Content, $StartText) !== false) 15 16 { 16 17 $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));20 18 $Content = substr($Content, strpos($Content, $StartDate) + strlen($StartDate)); 21 $Date = substr($Content, 0, strpos($Content, ' 19 $Date = substr($Content, 0, strpos($Content, '<')); 22 20 $DateParts = explode('.', $Date); 23 21 $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 25 29 26 27 /*28 30 echo('Title: '.$Title.'<br>'); 29 31 echo('Description: '.$Description.'<br>'); 30 32 echo('Date: '.$Date.'<br>'); 31 33 echo('Link: '.$Link.'<br><hr>'); 32 */ 34 33 35 34 36 $DbResult = $Database->select('News', 'Id', '`Title`="'.$Database->real_escape_string($Title).'" AND `Date`="'.$Date.'" AND `Category`='.$Category); -
trunk/database.php
r319 r320 33 33 var $PDO; 34 34 var $Error = ''; 35 var $insert_id; 36 var $LastQuery = ''; 35 37 36 38 function __construct($Host, $User, $Password, $Database) … … 51 53 global $Config; 52 54 55 $this->LastQuery = $Query; 53 56 if($Config['Web']['ShowSQLQuery'] == true) 54 57 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"); … … 85 88 $Values = substr($Values, 1); 86 89 $this->PDO->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 90 $this->insert_id = $this->PDO->lastInsertId(); 87 91 } 88 92 … … 121 125 } 122 126 127 function real_escape_string($Text) 128 { 129 return(addslashes($Text)); 130 } 131 123 132 } 124 133
Note:
See TracChangeset
for help on using the changeset viewer.