Veri tabanından veri çekerek sitemap hazırlama
126
●18.763
- 02-02-2008, 11:25:49
<? include "ayar.php"; include "fonk.php"; ?> <? $xml_ciktisi="<?xml version=\"1.0\" encoding=\"windows-1254\"?><urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd\">\n"; $urlset="</urlset>"; echo $xml_ciktisi; $x="1"; $cek=mysql_query("select * from oyunlar order by no desc limit 500"); while($veri=mysql_fetch_array($cek)) { ; ?> <? if($x=="498" OR $x=="499" OR $x=="500") { } else { echo ""; } ?> <url> <loc>http://www.onlineoyunoyna.com/<? echo $veri[no]; ?>-<? echo cevir($veri[ad]); ?>-oyunu.html</loc> <changefreq>daily</changefreq> <priority>0.5</priority> </url> <? $x++; } ?>çıktı sonunda </urlset> i nasıl veririm döngü sonunu ayarlıyamadım. - 17-02-2008, 23:29:55Üyeliği durdurulduarklar vbulletin için yapılmış olan sitemap ın kodlarını verebilirmi biri?
- 09-03-2008, 00:38:02bunları nukede de kullanabilir miyiz arkadaşlar ?dead86 adlı üyeden alıntı: mesajı görüntüle
ikincisini denedim olmadı. - 01-04-2008, 14:00:35
<!--#include file="dbbaglanti.asp"--> <% Function Urlekle(url,tarih,oncelik,guncellenme) etiket="<url>"&chr(10)&chr(13)&" <loc>"&url&"</loc>" if tarih<>"" then etiket=etiket&chr(10)&chr(13)&" <lastmod>"&tarih&"</lastmod>" end if etiket=etiket&chr(10)&chr(13)&" <changefreq>"&guncellenme&"</changefreq>" etiket=etiket&chr(10)&chr(13)&" <priority>"&oncelik&"</priority>"&chr(10)&chr(13)&" </url>" Urlekle=etiket End Function Set FSO = Server.CreateObject("Scripting.FileSystemObject") FSO.createTextFile Server.Mappath("sitemap.xml") set harita = FSO.openTextFile(Server.MapPath("sitemap.xml"),2,0) haritaveri=Urlekle("http://www.siteadi.com","","1.0","hourly") do while not rs.eof urlmiz = "http://www.siteadi.com/dosya.asp?dosya_id="&rs("id") tarih=year(rs("tarih"))&"-"&right("0"&month(rs("tarih")),2)&"-"&right("0"&day(rs("tarih")),2) haritaveri=haritaveri&chr(10)&chr(13)&chr(10)&chr(13)&Urlekle(urlmiz,""&tarih&"","0.5","weekly") rs.movenext loop rs.close set rs = nothing veri="<?xml version=""1.0"" encoding=""UTF-8""?>" veri=veri&"<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">" haritaveri=veri&haritaveri&"</urlset>" harita.write(haritaveri) harita.close set harita = nothing set FSO = nothing response.write "Sitemap dosyanız oluşturulmuştur.Oluşturulan sitemap dosyanızı görüntülemek için <a href="sitemap.xml">buraya</a> tıklayın." %>Sitem için bu mantıkta bir kod yazdım gayet güzel çalışıyor. Db den kayıtları çekip "sitemap.xml" dosyasına yazdırıyor. İçeriğinizi güncelledikçe girip bir kere bu dosyayı çalıştırın sitemap.xml dosyanız güncellenir.
Eğer google her geldiğinde sitemapın güncellenmesini istiyorsanız: yukarıdaki kodlardan şu kodları çıkarıp :
Set FSO = Server.CreateObject("Scripting.FileSystemObject") FSO.createTextFile Server.Mappath("sitemap.xml") set harita = FSO.openTextFile(Server.MapPath("sitemap.xml"),2,0)Bu bölümü de:veri="<?xml version=""1.0"" encoding=""UTF-8""?>" veri=veri&"<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">" haritaveri=veri&haritaveri&"</urlset>" harita.write(haritaveri) harita.close set harita = nothing set FSO = nothing
Aşağıdaki gibi değiştirin.
veri="<?xml version=""1.0"" encoding=""UTF-8""?>" veri=veri&"<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">" haritaveri=veri&haritaveri&"</urlset>" response.write haritaveri harita.close set harita = nothing set FSO = nothing
Veri tabanı + FSO + do while döngüsü ile sitemapımızı oluşturduk.
Zamanım az olmasa satır satır açıklardım. Şimdilik bunla idare edin
- 04-04-2008, 17:52:10Sitemap'ı farklı sayfalara bölebilirsin.saka adlı üyeden alıntı: mesajı görüntüle