| 
	
 | 
 Posted by Jerry Stuckle on 03/03/07 14:23 
onurpay@gmail.com wrote: 
> Güncel : is a category name in the txt file. 
> BCList2.txt : data file from another site 
> problem : the txt file is too big. it has lots of categories in it. i 
> need only "Güncel" category. also it is too slow to show that category 
> in my page. so i want to cache it maybe in a txt file in my server. so 
> second time that i need the data it won't be too slow. i want to take 
> the data once in a day but show several times. the code below is 
> working as well as i need. but it is too slow to open every time 
> refresh my page. if any suggestions, thank you. 
>  
> here is the code 
>  
> <? 
> if (!$kategori_haber) $kategori_haber = array("Güncel"); 
> $satir = file("http://www.ntvmsnbc.com/news/BCList2.txt") or 
> die("Serverla iletişim sağlanamadı!"); 
> for ($x = 0; $x < sizeof($kategori_haber); $x++) { 
> for ($i = 0; $i < sizeof($satir); $i++) { 
> if (trim($satir[$i]) == "+$kategori_haber[$x]") { 
> $bas = $i + 2; 
> break; 
> } 
> } 
> for ($i = $bas; $i < sizeof($satir); $i++) { 
> if (substr($satir[$i], 0, 1) == "+" || $i == sizeof($satir) - 1) { 
> $son = $i; 
> break; 
> } 
> } 
> for ($i = $bas; $i < $son; $i++) { 
> $yazi = trim($satir[$i]); 
> if ($yazi != "-" && !eregi("$kategori_haber[$x] Güncel", $yazi)) { 
> $yazi = str_replace("/news/./", "http://www.ntvmsnbc.com/news/", 
> $yazi); 
> $haber_e = explode("|", $yazi); 
> $haber_e[0]=str_replace("http://www.ntvmsnbc.com/news/", "", 
> $haber_e[0]); 
>         echo "·<font face=verdana size=1> <a href=\"http:// 
> www.ntvmsnbc.com/news/$haber_e[0]\" target=_blank >$haber_e[1]</a></ 
> font></br>\n"; 
> } 
> } 
> } 
> ?> 
>  
 
I agree with Jeff - if you're only using one category, create a static  
page.  Personally I think I'd do that with a cron job once a day to  
fetch the data and build the page. 
 
If you're looking at a lot of categories I'd recommend putting them into  
a relational database such as MySQL or PostGresSQL. 
 
--  
================== 
Remove the "x" from my email address 
Jerry Stuckle 
JDS Computer Training Corp. 
jstucklex@attglobal.net 
==================
 
  
Navigation:
[Reply to this message] 
 |