Volgograd

Волгоград Linux User Group

Организована 23 ноября 2002 года

Проект заморожен Птн Июл 6 02:11:14 MSD 2012


Вход:  Пароль:  

DwarfCC/source/ct.php


<?php

    header
("Content-type: text/xml");
    echo
'<?xml version="1.0" encoding="Windows-1251"?>';
?>


<rss version="2.0">
<channel>

<title>Компьюлента</title>
<link>http://www.compulenta.ru</link>
<description>Новости компьютерной индустрии, науки и техники.</description>
<image>
<title>Компьюлента</title>

<url>http://img.compulenta.ru/clenta/i/bigtitle.gif</url>
<link>http://www.compulenta.ru</link>
<width>88</width>
<height>31</height>
</image>






<?php

    
function rep_callback($m){
        
        
$title = $m[2];
        
$link = "http://www.computerra.ru/".$m[1]."/print.html";
        
        
$title = str_replace("&", "&amp;",$title);
        
$title = str_replace("<", "&lt;",$title);
        
$title = str_replace(">", "&gt;",$title);
        
        echo
"<item>";

        echo
"<title>";
        echo
$title;        
        echo
"</title>";
        echo
"<link>";
        echo
$link;
        echo
"</link>";

        echo
"<description>";
        echo
"NOT";
        echo
"</description>";
        
        echo
"<category>dummy</category>";
        
        echo
"<pubDate>now</pubDate>";
        
        echo
"</item>";
    
        return
"";
    }

    
$line = file_get_contents('http://www.computerra.ru/', 'r');
        
    
$pattern = '|<div class="item">.*<h2><a href="/(.*)/">(.*)</a></h2>.*</div>|sU';
    
    
//$pattern = '(<div class="item">.*<h2><a href="/.*/">(.*)</a></h2>.*</div>)';
    
    
preg_replace_callback($pattern, "rep_callback", $line);
    

?>


</channel>
</rss>