ShowPage = false; $System->Run(); $SourceURL = 'http://dviproduction.cz/video/playlist.xml'; $StartText = ''; $TitleSeparator = ''; $DescriptionSeparator = '<description>'; $StartLink = 'url="'; $Category = 13; $Author = 'Automat'; //$Encoding = new Encoding(); //$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250')); $Content = @file_get_contents($SourceURL); while (strpos($Content, $StartText) !== false) { $Content = substr($Content, strpos($Content, $StartText) + strlen($StartText)); $Title = substr($Content, strpos($Content, $TitleSeparator) + strlen($TitleSeparator)); $Title = substr($Title, 0, strpos($Title, '<')); $Description = substr($Content, strpos($Content, $DescriptionSeparator) + strlen($DescriptionSeparator)); $Description = trim(substr($Description, 0, strpos($Description, '<'))); $Content = substr($Content, strpos($Content, $StartLink) + strlen($StartLink)); $Link = substr($Content, 0, strpos($Content, '"')); // $Link = substr($Link, 0, strpos($Link, '?')); // Remove URL parameters // $Link = substr($Link, 0, strrpos($Link, '/')).substr($Link, strrpos($Link, '/')); // Insert month between folder and filename //echo('Title: '.$Title.'<br>'); //echo('Description: '.$Description.'<br>'); //echo('Link: '.$Link.'<br><hr>'); $DbResult = $System->Database->select('News', 'Id', '`Title`="'.$System->Database->real_escape_string($Title).'" AND `Category`='.$Category); //echo($System->Database->LastQuery); if ($DbResult->num_rows == 0) { $System->Database->insert('News', array('Title' => $Title, 'Date' => 'NOW()', 'Author' => $Author, 'Category' => $Category, 'Content' => $Description, 'Link' => $Link)); echo($System->Database->insert_id.','); } }