PHP: Как да записвам новите теми от форум в .txt файлове?

Нека бафиту да даде инфо как го е направил, но виж аз к'во направих :D

<?php
$file_to_read="last_topics.txt";
$xmlfile = fopen("http://web-tourist.net/rss_forum.php", "r");
if(!$xmlfile)die("cannot open the xml file");
$readfile = fread($xmlfile ,400000);
$searchfile = eregi("<item>(.*)</item>", $readfile ,$arrayreg);
$filechunks = explode("<item>", $arrayreg[0]);
$count = count($filechunks);
if($count>1){fopen($file_to_read, "w");}
for($i=1 ; $i<=$count-1 ;$i++)
{
ereg("<title>(.*)</title>",$filechunks[$i], $title);
ereg("<link>(.*)</link>",$filechunks[$i], $links);
$out_result="- ".$title[1]." LINK: ".$links[1]."<br />\n";
$handle = fopen($file_to_read, "a+");
fwrite($handle, $out_result);
fclose($handle);
}
?>


при всеки рефреш съдържанието на файла last_topics.txt се трие и се пълни с най-новото от WT :D
можеш да си редактираш променливата $file_to_read ;)
 
Dido_net каза:
Нека бафиту да даде инфо как го е направил, но виж аз к'во направих :D

<?php
$file_to_read="last_topics.txt";
$xmlfile = fopen("http://web-tourist.net/rss_forum.php", "r");
if(!$xmlfile)die("cannot open the xml file");
$readfile = fread($xmlfile ,400000);
$searchfile = eregi("<item>(.*)</item>", $readfile ,$arrayreg);
$filechunks = explode("<item>", $arrayreg[0]);
$count = count($filechunks);
if($count>1){fopen($file_to_read, "w");}
for($i=1 ; $i<=$count-1 ;$i++)
{
ereg("<title>(.*)</title>",$filechunks[$i], $title);
ereg("<link>(.*)</link>",$filechunks[$i], $links);
$out_result="- ".$title[1]." LINK: ".$links[1]."<br />\n";
$handle = fopen($file_to_read, "a+");
fwrite($handle, $out_result);
fclose($handle);
}
?>


при всеки рефреш съдържанието на файла last_topics.txt се трие и се пълни с най-новото от WT :D
можеш да си редактираш променливата $file_to_read ;)

Това скриптче мисля че ще ми свърши работа,
сега да започвам бота и ако нещо имам проблем
по скрипта ще пиша пак.
Поздрави :?:
 

Back
Горе